Skip to content
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
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ Note: you may refer to `README.md` for description of features.

## Dev (WIP)

## 1.0.3 (2025-01-17)
## 2.0.0 (2025-01-12)
- Adopted Laravel's `Number::fileSize()` to show the estimated evicted storage size stats
- Therefore, further requires `ext-intl`

## 1.0.3 (2025-01-07)
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
Expand All @@ -26,4 +30,3 @@ This is a utility library for Laravel that can efficiently remove many expired c
- 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

4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
],
"require": {
"php": "^8.1",
"ext-intl": "*",
"illuminate/support": "^10.0|^11.0",
"wilderborn/partyline": "^1.0"
},
Expand All @@ -50,5 +51,8 @@
"Vectorial1024\\LaravelCacheEvict\\CacheEvictServiceProvider"
]
}
},
"config": {
"sort-packages": true
}
}
8 changes: 3 additions & 5 deletions src/AbstractEvictStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Vectorial1024\LaravelCacheEvict;

use Illuminate\Console\OutputStyle;
use Illuminate\Support\Number;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\NullOutput;

Expand Down Expand Up @@ -41,10 +42,7 @@ abstract public function execute();
*/
protected function bytesToHuman(int $bytes): string
{
// 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];
// it turns out Laravel already has a helper for this
return Number::fileSize($bytes, 2, 2);
}
}
Loading