Skip to content

Conversation

@ndyakov
Copy link
Member

@ndyakov ndyakov commented Nov 5, 2025

Adding CAS/CAD commands available in redis 8.4:

SET key value [NX | XX
  | IFEQ match-value | IFNE match-value
  | IFDEQ match-digest | IFDNE match-digest] [GET]
# return changes:
# - if GET specified, returns previous value (regardless of IFEQ etc)
# - if GET not specified, nil reply if operation aborted due to IFEQ etc
DELEX key [IFEQ match-value | IFNE match-value
  | IFDEQ match-digest | IFDNE match-digest]
# returns integer of the number of keys that were removed (so: 0 or 1)
DIGEST key
# returns hex of the specified key (pending "null if not exists?")

I did change the methods and added *Get methods for each SetIF* method, since the responses mean different things (i.e. Set will return status OK but if it is set ... ifneq .. get it still can return OK if the previous value of the key was OK. This way it is more clear, the returned commands are StatusCmd or StringCmd and they both mean different things (should) to the user.
What is still a StatusCmd that can actually hold the previous value, is the return of SetArgs if we have Get=True in the args. Any feedback on how to handle this better is welcome.

@ndyakov ndyakov changed the title add cas/cad commands feat: Add CAS/CAD commands Nov 5, 2025
@ndyakov ndyakov changed the title feat: Add CAS/CAD commands feat(cmd): Add CAS/CAD commands Nov 5, 2025
ndyakov and others added 3 commits November 5, 2025 16:32
Decided to move the *Get argument as a separate methods, since the
response will be always the previous value, but in the case where
the previous value is `OK` there result may be ambiguous.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants