Adding support for CAS/CAD commands.#3837
Merged
petyaslavova merged 4 commits intomasterfrom Nov 11, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request adds support for two new Redis 8.4 commands (DELEX and DIGEST) and extends the SET command with new conditional options (IFEQ, IFNE, IFDEQ, IFDNE). The implementation includes both synchronous and asynchronous variants along with comprehensive test coverage.
Key Changes:
- Added
delex()method for conditional key deletion based on value or digest matching - Added
digest()method to compute XXH3 hash digests of string values - Extended
set()method with four new conditional parameters for atomic compare-and-set operations - Introduced
at_most_one_value_set()helper function to simplify mutual exclusivity validation - Added
DIGESTcommand to cluster read-only commands list
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| redis/commands/helpers.py | Adds at_most_one_value_set() helper function for mutual exclusivity checks |
| redis/commands/core.py | Implements delex() and digest() methods, extends set() with new conditionals, refactors mutual exclusivity checks |
| redis/commands/cluster.py | Adds DIGEST to read-only commands list for cluster support |
| tests/test_commands.py | Comprehensive tests for delex(), digest(), and extended set() functionality |
| tests/test_asyncio/test_commands.py | Async variants of all new tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9b65150 to
70aa89e
Compare
vladvildanov
approved these changes
Nov 11, 2025
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.
Adding support for new CAS/CAD commands that are part of Redis 8.4 release.
Adding new command: DIGEST
Command definition:
DIGEST keyGet the hash digest of the value stored in key, as a hex string.
Extending SET command to enable the following arguments:
Command definition:
SET key value [NX | XX | IFEQ match-value | IFNE match-value | IFDEQ match-digest | IFDNEmatch-digest] [GET] [EX seconds | PX milliseconds | EXAT unix-time-seconds | PXAT unix-time-milliseconds | KEEPTTL]IFEQ match-value - Set the key’s value and expiration only if its current value is equal to match-value. If key doesn’t exist - it won’t be created.
IFNE match-value - Set the key’s value and expiration only if its current value is not equal to match-value. If key doesn’t exist - it will be created.
IFDEQ match-digest - Set the key’s value and expiration only if the digest of its current value is equal to match-digest. If key doesn’t exist - it won’t be created.
IFDNE match-digest - Set the key’s value and expiration only if the digest of its current value is not equal to match-digest. If key doesn’t exist - it will be created.
Adding new command DELEX
Command definition:
DELEX key [IFEQ match-value | IFNE match-value | IFDEQ match-digest | IFDNE match-digest]Conditionally removes the specified key. A key is ignored if it does not exist.
IFEQ match-value - Delete the key only if its value is equal to match-value
IFNE match-value - Delete the key only if its value is not equal to match-value
IFDEQ match-digest - Delete the key only if the digest of its value is equal to match-digest
IFDNE match-digest - Delete the key only if the digest of its value is not equal to match-digest