Skip to content

Commit 8850c48

Browse files
Merge pull request #6 from Vectorial1024/rugpull_bad
Response to external rugpull
2 parents 9c4c463 + 56e6873 commit 8850c48

File tree

4 files changed

+39
-7
lines changed

4 files changed

+39
-7
lines changed

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Change Log of `laravel-cache-evict`
2+
Note: you may refer to `README.md` for description of features.
3+
4+
## Dev (WIP)
5+
6+
## 1.0.3 (2025-01-17)
7+
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!!!
8+
- No longer depends on `ramazancetinkaya/byte-formatter` as culprit of rugpull
9+
- A StackOverflow-copied solution is being used for now
10+
- A proper solution will be made later
11+
- Added a changelog at `ChANGELOG.md`
12+
13+
## 1.0.2 (2024-10-29)
14+
Hotfix: avoid `database` eviction race condition (38d70027b1778685a3c5ddffb4e10a9892bf4896); improve test case stability (2f7fecf581d5598231671ba5511e219aa94122b3)
15+
16+
## 1.0.1 (2024-10-29)
17+
The v1.0.1 release of the library.
18+
- Added the earlier-promised auto tests (#2)
19+
- Reorganized the README
20+
- Removed `package.json` (#2) to fix possible installation failures
21+
22+
## 1.0.0 (2024-10-27)
23+
Initial release.
24+
25+
This is a utility library for Laravel that can efficiently remove many expired cache items in Laravel to prevent storage overload.
26+
- Supports the `file` and `database` cache driver
27+
- Supports self-defined cache eviction strategies
28+
- Uses PHP generators to avoid using too much memory while scanning for expired items
29+

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ Some drivers (e.g. `memcached`, `redis`) will never be supported because they ha
3939

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

42+
### Change log
43+
Please see `CHANGELOG.md`.
44+
4245
## Usage
4346

4447
You may run this in the command line:
@@ -94,7 +97,7 @@ php artisan cache:evict local_store
9497
... 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).
9598

9699
## Testing
97-
Using `orchestra/testbench` (customized PHPUnit) via Composer:
100+
PHPUnit (using `orchestra/testbench`) via Composer:
98101

99102
```sh
100103
composer run-script test

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434
"require": {
3535
"php": "^8.1",
3636
"illuminate/support": "^10.0|^11.0",
37-
"wilderborn/partyline": "^1.0",
38-
"ramazancetinkaya/byte-formatter": "^1.0"
37+
"wilderborn/partyline": "^1.0"
3938
},
4039
"require-dev": {
4140
"ext-sqlite3": "*",

src/AbstractEvictStrategy.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Vectorial1024\LaravelCacheEvict;
44

55
use Illuminate\Console\OutputStyle;
6-
use ramazancetinkaya\ByteFormatter;
76
use Symfony\Component\Console\Input\StringInput;
87
use Symfony\Component\Console\Output\NullOutput;
98

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

0 commit comments

Comments
 (0)