Skip to content

Conversation

@petyaslavova
Copy link
Collaborator

Adding support for new CAS/CAD commands that are part of Redis 8.4 release.

  1. Adding new command: DIGEST
    Command definition: DIGEST key
    Get the hash digest of the value stored in key, as a hex string.

  2. Extending SET command to enable the following arguments:
    Command definition: SET key value [NX | XX | IFEQ match-value | IFNE match-value | IFDEQ match-digest | IFDNE match-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.

  3. 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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 DIGEST command 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.

petyaslavova and others added 2 commits November 6, 2025 20:27
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants