Skip to content

Comments

Added support for Redis 8.4 DELEX command.#3318

Open
Dgramada wants to merge 2 commits intospring-projects:mainfrom
Dgramada:topic/integrate-DELEX-command
Open

Added support for Redis 8.4 DELEX command.#3318
Dgramada wants to merge 2 commits intospring-projects:mainfrom
Dgramada:topic/integrate-DELEX-command

Conversation

@Dgramada
Copy link
Contributor

@Dgramada Dgramada commented Feb 23, 2026

This change introduces the DELEX string command feature as part of the features provided by the spring-data-redis project.

This feature is available starting from Redis OSS version 8.4 and later

  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

Implemented the DELEX command that conditionally deletes a key based on value comparison.

Signed-off-by: Yordan Tsintsov <yordan.tsintsov@redis.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 23, 2026
Copy link
Member

@mp911de mp911de left a comment

Choose a reason for hiding this comment

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

Only two minor things to address. We need to discuss method naming for the API. CAS-wise, compareAndDelete(…) would be a great fit, but we have to accomodate the ifNotEquals factor.

}

@Test
@EnabledOnRedisVersion("8.4")
Copy link
Member

Choose a reason for hiding this comment

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

We prefer @EnabledOnCommand("DELEX") gurards

* @see <a href="https://redis.io/commands/delex">Redis Documentation: DELEX</a>
* @since 4.2
*/
@NonNull Boolean deleteIfNotEqual(@NonNull K key, @NonNull V value);
Copy link
Member

Choose a reason for hiding this comment

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

@NonNull Boolean isn't right here as the return value can be null when used in transactions. Just Boolean is fine.

@mp911de mp911de added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Feb 23, 2026
…Operations.java and replaced test annotation to be command-specific instead of version-specific.

Signed-off-by: Yordan Tsintsov <yordan.tsintsov@redis.com>
@Dgramada
Copy link
Contributor Author

I should mention that CAS/CAD operations in Redis also support two more options - IF_DIGEST_EQUAL and IF_DIGEST_NOT_EQUAL, which could be added at some point as well.

Maybe we should take this into consideration, while naming the current template CAS/CAD methods.

We could then name the methods something like:

  • compareAndDelete (instead of deleteIfEqual)
  • compareAndDeleteIfDifferent (instead of deleteIfNotEqual)
  • compareDigestAndDelete (potential name if digest logic is added at some point in the future)
  • compareDigestAndDeleteIfDifferent (potential name if digest logic is added at some point in the future)

@mp911de
Copy link
Member

mp911de commented Feb 24, 2026

We want to avoid uncontrolled growth in method (name) overload variants. Our current thinking is at compareAndDelete(K key, V oldValue, V newValue) and compareAndDelete(K key, CasOperator<V> oldValue, V newValue) where CasOperator (or a better name) can be CasOperator.ifEqual(…), CasOperator.ifNotEqual(…) and so on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants