Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Response to external rugpull #6

Merged
merged 4 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Change Log of `laravel-cache-evict`
Note: you may refer to `README.md` for description of features.

## Dev (WIP)

## 1.0.3 (2025-01-17)
Special note: this update is made in response to the external rugpull as discovered in #4. All previous versions are "tainted" and will not be supported, effective immediately. Update your installed version now!!!
- No longer depends on `ramazancetinkaya/byte-formatter` as culprit of rugpull
- A StackOverflow-copied solution is being used for now
- A proper solution will be made later
- Added a changelog at `ChANGELOG.md`

## 1.0.2 (2024-10-29)
Hotfix: avoid `database` eviction race condition (38d70027b1778685a3c5ddffb4e10a9892bf4896); improve test case stability (2f7fecf581d5598231671ba5511e219aa94122b3)

## 1.0.1 (2024-10-29)
The v1.0.1 release of the library.
- Added the earlier-promised auto tests (#2)
- Reorganized the README
- Removed `package.json` (#2) to fix possible installation failures

## 1.0.0 (2024-10-27)
Initial release.

This is a utility library for Laravel that can efficiently remove many expired cache items in Laravel to prevent storage overload.
- Supports the `file` and `database` cache driver
- Supports self-defined cache eviction strategies
- Uses PHP generators to avoid using too much memory while scanning for expired items

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ Some drivers (e.g. `memcached`, `redis`) will never be supported because they ha

Custom eviction strategies can be defined for other cache drivers that does not have their own eviction mechanisms (see FAQ section).

### Change log
Please see `CHANGELOG.md`.

## Usage

You may run this in the command line:
Expand Down Expand Up @@ -94,7 +97,7 @@ php artisan cache:evict local_store
... then, you will only evict the `local_store` cache. The `another_store` cache is unaffected by this command (assuming both are using separate directories, of course).

## Testing
Using `orchestra/testbench` (customized PHPUnit) via Composer:
PHPUnit (using `orchestra/testbench`) via Composer:

```sh
composer run-script test
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
"require": {
"php": "^8.1",
"illuminate/support": "^10.0|^11.0",
"wilderborn/partyline": "^1.0",
"ramazancetinkaya/byte-formatter": "^1.0"
"wilderborn/partyline": "^1.0"
},
"require-dev": {
"ext-sqlite3": "*",
Expand Down
9 changes: 5 additions & 4 deletions src/AbstractEvictStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Vectorial1024\LaravelCacheEvict;

use Illuminate\Console\OutputStyle;
use ramazancetinkaya\ByteFormatter;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\NullOutput;

Expand Down Expand Up @@ -42,8 +41,10 @@ abstract public function execute();
*/
protected function bytesToHuman(int $bytes): string
{
// in case the library broke, we can refer to this link: https://stackoverflow.com/questions/15188033/human-readable-file-size
$formatter = new ByteFormatter();
return $formatter->format($bytes);
// the guy did a rugpull; the link turned out to be very handy.
// see https://stackoverflow.com/questions/15188033/human-readable-file-size
$units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
for ($i = 0; $bytes > 1024; $i++) $bytes /= 1024;
return round($bytes, 2) . ' ' . $units[$i];
}
}
Loading