HLEN(3valkey)
β¨ 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:
hdel(3valkey),hexists(3valkey),hexpire(3valkey),hexpireat(3valkey),hexpiretime(3valkey),hget(3valkey),hgetall(3valkey),hgetex(3valkey),hincrby(3valkey),hincrbyfloat(3valkey),hkeys(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)
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
- 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