-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Description
Laravel Version
11.39.0
PHP Version
8.4.3
Database Driver & Version
No response
Description
When using Redis as a cache driver combined with compression or serialization, the rate limiter no longer works in the latest release: the increment method always returns 0.
This seems to be related to #54221
More specifically, it seems that adding a key and then incrementing that key is the thing that breaks the rate limiter
$added = $this->cache->add($key, 0, $decaySeconds);
$hits = (int) $this->cache->increment($key, $amount);
doing the above always returns 0.
That's because the incrby function in Redis only works on integers, not on serialized/compressed data.
I can try and submit a PR with a fix, but I'm not sure what the preferred way forward would be.
Steps To Reproduce
I created a test case here: JeppeKnockaert/laravel-cache-bug-report@e983654
To execute the tests:
cp .env.example .env
./vendor/bin/sail artisan key:generate
./vendor/bin/sail up -d
./vendor/bin/sail test ./tests/Unit/CacheTest.php
The first test is the only that succeeds, because no compression or serialisation are configured.