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.

HGETDEL

Last updated
HGETDEL key FIELDS numfields field [field ...]
Group
Hash
Complexity
O(N) where N is the number of fields given
Arity
-5 (at least 5 words, counting the command name)
Flags
write, fast
Keys
first 1, last 1, step 1
HotKV Cloud
All plans
On-Premise
no license needed

HGETDEL returns the values of the listed fields of the hash at key and removes those fields, atomically. Fields that do not exist give a nil and are otherwise ignored. When the last field is removed, the key is deleted.

FIELDS must come right after the key, and numfields must equal the number of field names that follow.

Case RESP2 RESP3
Success Array with one entry per field: the value as a bulk string, or nil bulk string if the field did not exist Array of bulk strings, with null for a missing field
Key does not exist Array of nils, one per field Array of nulls

Errors:

  • WRONGTYPE if key holds a value that is not a hash.
  • ERR Mandatory argument FIELDS is missing or not at the right position.
  • ERR Number of fields must be a positive integer.
  • ERR The `numfields` parameter must match the number of arguments.
127.0.0.1:6379> HSET job:5 state "ready" owner "w1"
(integer) 2
127.0.0.1:6379> HGETDEL job:5 FIELDS 2 state missing
1) "ready"
2) (nil)
127.0.0.1:6379> HGETDEL job:5 FIELDS 1 owner
1) "w1"
127.0.0.1:6379> EXISTS job:5
(integer) 0

Same as Redis 8.0. Redis 7.4 and Valkey 8 do not have this command.

HGETEX, HDEL, HMGET, GETDEL