Repository navigation
fix: use __ci_value field in PredisHandler::increment() and decrement() - #10758
Conversation
|
Thank you @banghamid for spotting this and submitting a clean fix! Review Summary: Approve
Optional suggestion (nitpick / non-blocking)Both $this->assertSame(135, $this->handler->decrement('counter', 20));
$this->assertSame(135, $this->handler->get('counter')); |
|
thanks @gr8man! good catch, makes sense to check the return value directly too. just pushed an update to testIncrementAndDecrement() to assert the returned int from increment() and decrement() as well. |
__ci_value field in PredisHandler::increment() and decrement()
paulbalandan
left a comment
There was a problem hiding this comment.
Please add a changelog entry describing the fix for existing counters. On a missing key, increment and decrement can still return a number while get() returns null because the hash lacks __ci_type. That predates this PR, so please keep the description scoped to existing entries.
9f87b87 to
4e210f5
Compare
|
@paulbalandan Done — added a changelog entry in \docs/changelogs/v4.7.7.md\ scoped to existing counters, and rebased onto the latest \develop. |
Description
PredisHandler::save()andPredisHandler::get()store and read cached values in a Redis hash using the'__ci_type'and'__ci_value'fields. However,PredisHandler::increment()andPredisHandler::decrement()were still callinghincrby()on the legacy'data'field instead of'__ci_value'.As a result, calling
increment()ordecrement()modified the unused'data'hash field while leaving'__ci_value'unchanged, causing subsequent calls toget()to return the stale value.This PR:
PredisHandler::increment()andPredisHandler::decrement()to target the'__ci_value'hash field (consistent withRedisHandler::increment()).testIncrementAndDecrement()toPredisHandlerTest.Checklist: