HGETDEL
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.
Return value
Section titled “Return value”| 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:
WRONGTYPEifkeyholds 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.
Examples
Section titled “Examples”127.0.0.1:6379> HSET job:5 state "ready" owner "w1"(integer) 2127.0.0.1:6379> HGETDEL job:5 FIELDS 2 state missing1) "ready"2) (nil)127.0.0.1:6379> HGETDEL job:5 FIELDS 1 owner1) "w1"127.0.0.1:6379> EXISTS job:5(integer) 0Compatibility
Section titled “Compatibility”Same as Redis 8.0. Redis 7.4 and Valkey 8 do not have this command.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.