HLEN(3valkey)

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

✨ HLEN πŸ’…

okay so bestie, welcome to HLEN from the Valkey Command Manual β€” it's giving "count my fields" energy and honestly? she's iconic for it πŸŽ€


🌸 NAME 🌸

hlen β€” returns the number of fields in a hash. that's it. that's the whole job. queen of knowing how many things are in the thing πŸ‘‘


πŸ¦‹ SYNOPSIS πŸ¦‹

HLEN key

πŸ’– DESCRIPTION πŸ’–

so like, HLEN returns the number of fields contained in the hash stored at key. that's the tea β˜•


⭐ REPLY ⭐

valkey-protocol(7) Integer reply: the number of fields in the hash β€” or 0 when the key does not exist. no key, no fields, no drama, just a lil zero 🫢


πŸ”₯ COMPLEXITY πŸ”₯

O(1) β€” literally constant time, she does not stress, she does not scroll the whole hash, she just knows ✨


πŸ‘‘ ACL CATEGORIES πŸ‘‘

  • @fast
  • @hash
  • @read

three lil badges and she earned every single one πŸ’…


🌈 HISTORY 🌈

  • Available since: 2.0.0 β€” yeah she's been here since forever, an OG, a legend, main character energy from day one πŸ’€

πŸŽ€ EXAMPLES πŸŽ€

127.0.0.1:6379> HSET myhash field1 "Hello"
(integer) 1
127.0.0.1:6379> HSET myhash field2 "World"
(integer) 1
127.0.0.1:6379> HLEN myhash
(integer) 2

see how we set two fields and then she said 2? not me getting emotional over a correct integer reply 😭 ate and left no crumbs πŸ“


🧚 SEE ALSO 🧚

the whole hash fam, go say hi:


and that's the whole page, bestie!! this was Valkey 9.0.0, dated 2025-10-21 β€” mwah, go count some fields, ily πŸ«ΆπŸ’œβœ¨

πŸ“¦ where this page comes from