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.

GETDEL

Last updated
GETDEL key
Group
String
Complexity
O(1)
Arity
2 (exactly, counting the command name)
Flags
write, fast
Keys
first 1, last 1, step 1
HotKV Cloud
All plans
On-Premise
no license needed

GETDEL reads the string at key and deletes the key in the same step, so no other client can read the value in between. Use it to consume one-time values such as tokens.

Case RESP2 RESP3
The key held a string Bulk string: the value Bulk string
The key does not exist Nil bulk string Null

GETDEL replies with a WRONGTYPE error, and deletes nothing, when the key holds a value that is not a string.

127.0.0.1:6379> SET otp:42 "839201"
OK
127.0.0.1:6379> GETDEL otp:42
"839201"
127.0.0.1:6379> GETDEL otp:42
(nil)

Same as Redis 7 and Valkey 8.

GET, GETEX, DEL