HDEL(3valkey)

πŸ“¦
version 9.0.6 Β· 2 versions
, in fedora 44

✨ 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 πŸ”₯


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