feat(string): support IFEQ/IFNE/IFDEQ/IFDNE in SET command (#3311)#3393
Open
kirito632 wants to merge 4 commits intoapache:unstablefrom
Open
feat(string): support IFEQ/IFNE/IFDEQ/IFDNE in SET command (#3311)#3393kirito632 wants to merge 4 commits intoapache:unstablefrom
kirito632 wants to merge 4 commits intoapache:unstablefrom
Conversation
Member
When GET is combined with IFEQ/IFNE/IFDEQ/IFDNE and the condition is not met, return the previous value (not nil), consistent with how Redis handles GET+NX/XX and the official Redis 8.x documentation.
When GET is combined with a conditional SET (IFEQ/IFNE/IFDEQ/IFDNE), the previous value is always returned regardless of whether the condition was met. The Go test incorrectly expected nil when the condition was not met; fix it to expect the old value. Also replace non-ASCII arrow characters in C++ test comments with plain ASCII equivalents to match kvrocks coding conventions.
Author
|
Thanks for the pointer. I used AI tools to assist with the initial implementation draft and test scaffolding. I reviewed the logic myself against the Redis 8.x documentation, caught and fixed a wrong test assertion (GET+IFEQ condition-not-met should return the old value, not nil), and cleaned up non-ASCII comments to match kvrocks conventions. I understand the implementation and can explain any part of it. |
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.
What this PR does / why we need it
This PR implements the
IFEQ,IFNE,IFDEQ, andIFDNEoptions for theSETcommand, resolving #3311.IFEQ <value>: only set if key exists and current value equals<value>IFNE <value>: only set if key does not exist, or current value differs from<value>IFDEQ <digest>: only set if key exists and digest of current value equals<digest>IFDNE <digest>: only set if key does not exist, or digest of current value differs from<digest>Which issue(s) this PR fixes
Closes #3311
Test coverage
GETandTTLcombinationsTestSetConditionalcovering syntax errors,basic behavior, GET/EX combinations, and 10 property-based tests
AI assistance
AI tools were used for the initial implementation draft and test scaffolding.
Logic was reviewed manually against the Redis 8.x documentation and kvrocks
coding conventions.