Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

DELEX

Last updated
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.

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

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.

127.0.0.1:6379> SET session:1 token-a
OK
127.0.0.1:6379> DELEX session:1 IFEQ token-b
(integer) 0
127.0.0.1:6379> DELEX session:1 IFNE token-a
(integer) 0
127.0.0.1:6379> DELEX session:1 IFEQ token-a
(integer) 1
127.0.0.1:6379> DELEX session:1
(integer) 0
127.0.0.1:6379> SET session:1 token-a
OK
127.0.0.1:6379> DELEX session:1 IFDNE 0123456789abcdef
(integer) 1
127.0.0.1:6379> DELEX session:1 IFDEQ 0123456789abcdef
(integer) 0

A Redis 8.4 command, with the same conditions as the IFEQ, IFNE, IFDEQ and IFDNE options of SET.

DIGEST, SET, DEL, UNLINK