DELEX
DELEX key [IFEQ ifeq-value | IFNE ifne-value | IFDEQ ifdeq-digest | IFDNE ifdne-digest]
- Available since:
- Redis Open Source 8.4.0
- Time complexity:
- O(1) for IFEQ/IFNE, O(N) for IFDEQ/IFDNE where N is the length of the string value.
- ACL categories:
-
@write,@string,@fast, - Compatibility:
- Redis Software and Redis Cloud compatibility
Conditionally removes the specified key based on value or hash digest comparison.
Required arguments
key
The name of the key to delete.
Optional arguments
The following options condition the deletion on the key's current value or hash digest. Only one may be specified.
IFEQ ifeq-value
Delete the key only if its value is equal to ifeq-value.
IFNE ifne-value
Delete the key only if its value is not equal to ifne-value.
IFDEQ ifdeq-digest
Delete the key only if its hash digest is equal to ifdeq-digest.
IFDNE ifdne-digest
Delete the key only if its hash digest is not equal to ifdne-digest.
In 8.4, keys must be of type string when using one of the options above. If no options are specified, the key is removed regardless of its type.
Details
Hash Digest
A hash digest is a fixed-size numerical representation of a string value, computed using the XXH3 hash algorithm. Redis uses this hash digest for efficient comparison operations without needing to compare the full string content. You can retrieve a key's hash digest using the DIGEST command, which returns it as a hexadecimal string that you can use with the IFDEQ and IFDNE options, and also the SET command's IFDEQ and IFDNE options.
Redis Software and Redis Cloud compatibility
| Redis Software |
Redis Cloud |
Notes |
|---|---|---|
| ❌ Standard |
❌ Standard |
Return information
One of the following:
- Integer reply: 0 if not deleted (the key does not exist or a specified
IFEQ/IFNE/IFDEQ/IFDNEcondition is false), or 1 if deleted. - Simple error reply if the key exists but holds a value that is not a string and one of
IFEQ, IFNE, IFDEQ,orIFDNEis specified.