Repository navigation
fix(rueidiscompat): set IsCacheHit for cached IntCmd and DurationCmd results - #1033
Open
NotAFlightRisk wants to merge 1 commit into
Open
NotAFlightRisk wants to merge 1 commit into
NotAFlightRisk wants to merge 1 commit into
Conversation
rueian
approved these changes
Oct 10, 2026
NotAFlightRisk
force-pushed
the
fix-compat-cachehit-intcmd
branch
from
October 13, 2026 05:51
3af7209 to
6514b2c
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Running
SCardandTTLtwice each throughcompat.Cache(time.Minute)on v1.0.78, both still sayIsCacheHit()is false the second time round, whileGeton the same adapter flips to true. The replies really are coming strait out of the client-side cache (a plainDoCacheof the same SCARD reports a hit), it's just the flag.IntCmdnever picked up the cache-hit line when #959 added it, so that's every cached call that returns one (StrLen,LLen,ZCard,BitCountand so on).DurationCmdand theJSONObjKeyspath inSliceCmddo set it, but after an early return, which is whyTTLonly ever reported a hit for keys with no TTL.With this the second
SCardandTTLboth come back as hits.Note
Low Risk
Small metadata fix in command wrappers with regression tests; no change to Redis protocol, auth, or data semantics.
Overview
Fixes incorrect
IsCacheHit()reporting on the go-redis compatibility layer when using client-side caching (compat.Cache/DoCache).IntCmdnow copiesres.IsCacheHit()infrom, so cached integer replies (e.g.SCard,StrLen,LLen,ZCard) report a hit on repeat calls.DurationCmdsets the flag on the positive-TTL early-return path soTTLand similar commands report hits when the cached value is > 0.SliceCmdsets the flag before returning on the JSON.OBJKEYS (json: true) path.Adds
TestCacheHitFromCachedResultto assertIntCmd,DurationCmd, and JSONSliceCmdreturnIsCacheHit() == truefor cache-marshaled mock results.Reviewed by Cursor Bugbot for commit 6514b2c. Bugbot is set up for automated code reviews on this repo. Configure here.