GETDEL
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.
Return value
Section titled “Return value”| 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.
Examples
Section titled “Examples”127.0.0.1:6379> SET otp:42 "839201"OK127.0.0.1:6379> GETDEL otp:42"839201"127.0.0.1:6379> GETDEL otp:42(nil)Compatibility
Section titled “Compatibility”Same as Redis 7 and Valkey 8.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.