Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
RedisCacheStore
INCR/DECR for Redis < v7.0.0
This commit fixes a discrepancy in the behavior of the `#increment` and `#decrement` methods in `RedisCacheStore` when used with Redis versions less than 7.0.0. The existing condition `count != amount` prevented setting the Time-To-Live (TTL) for keys that were equal to the increment/decrement amount after the `INCRBY`/`DECRBY` operation. This occurs when incrementing a non-existent key by `1`, for example. Using Redis pipelining, we minimize the network overhead incurred by checking for existing TTLs. It decouples the TTL operations from the increment/decrement operation, allowing the TTL to be set correctly regardless of the resulting value from the `INCRBY`/`DECRBY`. New tests have been added to verify the correct behavior of `#increment` and `#decrement` methods, specifically when the `expires_in` option is not used. Using a separate cache store instance (`@cache_no_ttl`), these tests ensure that keys are correctly incremented or decremented and that their TTL remains unset. Co-authored-by: Benjamin Quorning <benjamin@quorning.net> Co-authored-by: Jury Razumau <jury.razumau@zendesk.com> Co-authored-by: Edyta Rozczypała <edyta.rozczypala@zendesk.com>
- Loading branch information
1 parent
358d3d3
commit 600a052
Showing
2 changed files
with
61 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters