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 6 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.
@ndyakov
Copy link
Member Author

ndyakov commented Nov 6, 2025

I am considering changing the digest to uint64 to match https://github.com/zeebo/xxh3 and add documentation to suggest using https://github.com/zeebo/xxh3 for generating digests on the application level.

@ndyakov ndyakov force-pushed the ndyakov/CAE-1672-cas-cad branch from 6af5087 to bdefae8 Compare November 6, 2025 22:21
@ndyakov ndyakov force-pushed the ndyakov/CAE-1672-cas-cad branch from bdefae8 to 3a31338 Compare November 6, 2025 22:47
Copy link
Collaborator

@ofekshenawa ofekshenawa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ndyakov ndyakov merged commit 5069fd6 into master Nov 7, 2025
22 checks passed
@ndyakov ndyakov deleted the ndyakov/CAE-1672-cas-cad branch November 7, 2025 11:31
htemelski-redis pushed a commit that referenced this pull request Nov 10, 2025
* add cas/cad commands

* feat(command): Add SetIFDEQ, SetIFDNE and *Get cmds

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.

* fix tests

* matchValue to be interface{}

* Only Args approach for DelEx

* use uint64 for digest, add example

* test only for 8.4
htemelski-redis added a commit that referenced this pull request Nov 11, 2025
* Added hybrid search command

* fixed lint, fixed some tests

* lint fix

* Add support for XReadGroup CLAIM argument (#3578)

* Add support for XReadGroup CLAIM argument

* modify tutorial tests

---------

Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com>

* feat(acl): add acl support and  test (#3576)

* feat: add acl support and command test

* validate client name before kill it

---------

Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com>

* feat(cmd): Add support for MSetEX command (#3580)

Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com>

* fix(sentinel): handle empty address (#3577)

* improvements

* linter fixes

* prevention on unnecessary allocations in case of bad configuration

* Test/Benchmark, old code with safety harness preventing panic

---------

Co-authored-by: manish <manish.sharma@manifestit.io>
Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com>

* feat: support for latency command (#3584)

* support for latency command

* add NonRedisEnterprise label for latency test

* feat: Add support for certain slowlog commands (#3585)

* Add support for certain slowlog commands

* add NonRedisEnterprise label for slow reset test

---------

Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com>

* feat(cmd): Add CAS/CAD commands (#3583)

* add cas/cad commands

* feat(command): Add SetIFDEQ, SetIFDNE and *Get cmds

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.

* fix tests

* matchValue to be interface{}

* Only Args approach for DelEx

* use uint64 for digest, add example

* test only for 8.4

* updated ft hybrid, marked as experimental

* updated fthybrid and its tests

* removed debugging prints

* fixed lint, addressed comment

* fixed issues

* fixed lint

* Ensure that the args are prefixed only if theres no prefix already

* Removed automatic args prefixing

---------

Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com>
Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com>
Co-authored-by: destinyoooo <57470814+destinyoooo@users.noreply.github.com>
Co-authored-by: manish <bhardwaz007@yahoo.com>
Co-authored-by: manish <manish.sharma@manifestit.io>
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.

3 participants