DELEX
DELEX key [IFEQ value | IFNE value | IFDEQ digest | IFDNE digest]
- Group
- String
- Complexity
- O(1)
- Arity
- -2 (at least 2 words, counting the command name)
- Flags
- write, fast
- Keys
- first 1, last 1, step 1
- HotKV Cloud
- All plans
- On-Premise
- no license needed
DELEX deletes key. With a condition it deletes the key only when the
string stored there meets it, which lets you release a lock or an expiring
token without deleting a value that someone else has written since you read
it. Without a condition it deletes the key whatever it holds.
Options
Section titled “Options”| Option | Deletes the key when |
|---|---|
IFEQ value |
the string equals value |
IFNE value |
the string does not equal value |
IFDEQ digest |
the DIGEST of the string equals digest |
IFDNE digest |
the digest of the string does not equal digest |
Return value
Section titled “Return value”Integer 1 if the key was deleted, 0 if it did not exist or the condition
was not met, in RESP2 and RESP3. A condition without its argument, or no key,
is ERR wrong number of arguments for 'delex' command.
Examples
Section titled “Examples”127.0.0.1:6379> SET session:1 token-aOK127.0.0.1:6379> DELEX session:1 IFEQ token-b(integer) 0127.0.0.1:6379> DELEX session:1 IFNE token-a(integer) 0127.0.0.1:6379> DELEX session:1 IFEQ token-a(integer) 1127.0.0.1:6379> DELEX session:1(integer) 0127.0.0.1:6379> SET session:1 token-aOK127.0.0.1:6379> DELEX session:1 IFDNE 0123456789abcdef(integer) 1127.0.0.1:6379> DELEX session:1 IFDEQ 0123456789abcdef(integer) 0Compatibility
Section titled “Compatibility”A Redis 8.4 command, with the same conditions as the IFEQ, IFNE, IFDEQ
and IFDNE options of SET.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.