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.

HDEL

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

HDEL removes the given fields, and any time to live they had, from the hash stored at key. Fields that do not exist are ignored. When the last field is removed, the key itself is deleted.

Case RESP2 RESP3
Success Integer: the number of fields that were removed Same
Key does not exist Integer 0 Same

HDEL replies with a WRONGTYPE error if key holds a value that is not a hash.

127.0.0.1:6379> HSET user:1 name "Ada" lang "en"
(integer) 2
127.0.0.1:6379> HDEL user:1 lang missing
(integer) 1
127.0.0.1:6379> HDEL user:1 name
(integer) 1
127.0.0.1:6379> EXISTS user:1
(integer) 0

Same as Redis 7.4 and Valkey 8.

HSET, HGETDEL, HEXISTS, DEL