HDEL(3valkey)
β¨ HDEL (in the 3valkey manual, bestie) β¨
okay so this is the Valkey Command Manual page for hdel and it's literally the glow-up-your-hash command π
πΈ NAME πΈ
hdel β deletes one or more fields and their values from a hash. Deletes the hash if no fields remain.
π SYNOPSIS π
HDEL key field [field...]
π¦ DESCRIPTION π¦
Removes the specified fields from the hash stored at key. Specified fields that do not exist within this hash are ignored (no drama, no error, we just move on). And if key doesn't exist at all? It gets treated like an empty hash, and this command returns 0. periodt.
π REPLY π
valkey-protocol(7) Integer reply: the number of fields that were removed from the hash, excluding any specified but non-existing fields.
So like, if you asked to delete stuff that wasn't even there, that doesn't count. we're only counting the actual removals, no cap.
π§ COMPLEXITY π§
O(N) where N is the number of fields to be removed.
π ACL CATEGORIES π
@fast @hash @write
β HISTORY β
- Available since: 2.0.0
- Changed in 2.4.0: Accepts multiple field arguments.
(the way it started with just one field and then got the multiple-field upgradeβ¦ growth π)
π EXAMPLES π
127.0.0.1:6379> HSET myhash field1 "foo"
(integer) 1
127.0.0.1:6379> HDEL myhash field1
(integer) 1
127.0.0.1:6379> HDEL myhash field2
(integer) 0
see how the last one is 0? yeah, field2 was never there, so nothing got removed. iconic behavior tbh.
π₯ SEE ALSO π₯
hexists(3valkey)hexpire(3valkey)hexpireat(3valkey)hexpiretime(3valkey)hget(3valkey)hgetall(3valkey)hgetex(3valkey)hincrby(3valkey)hincrbyfloat(3valkey)hkeys(3valkey)hlen(3valkey)hmget(3valkey)hmset(3valkey)hpersist(3valkey)hpexpire(3valkey)hpexpireat(3valkey)hpexpiretime(3valkey)hpttl(3valkey)hrandfield(3valkey)hscan(3valkey)hset(3valkey)hsetex(3valkey)hsetnx(3valkey)hstrlen(3valkey)httl(3valkey)hvals(3valkey)
that's the whole page, bestie π«Ά this is version 9.0.0 of the docs, dated 2025-10-21 β so go forth, delete your fields, and slay π
β¨
π¦ where this page comes from
- fedora 44: valkey-doc 9.0.3-2.fc44 Β· CC-BY-SA-4.0
- fedora 44: valkey-doc 9.0.6-1.fc44 Β· CC-BY-SA-4.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms