HGETALL(3valkey)
π HGETALL β the Valkey command manual page, bestie edition π
okay so real quick before anything: this is hgetall(3valkey) from the Valkey Command Manual, and I'm about to make it make sense. sit down, hydrate, let's go π«Ά
β¨ NAME β¨
hgetall β returns all fields and values in a hash. every single one. the whole roster. no crumbs left π
β¨ SYNOPSIS β¨
HGETALL key
that's it. one argument. one command. iconic behavior honestly πΈ
β¨ DESCRIPTION β¨
So like, HGETALL returns all fields and values of the hash stored at key.
And here's the thing you gotta clock: in the value it hands back, every field name is followed by its value. so like, field, value, field, value, field, value β they alternate. which means the length of the reply is twice the size of the hash. twice!! because every field brings its value along like a plus-one to the function π
ngl that's the detail that trips people up, so remember it fr fr.
β¨ REPLY β¨
π RESP2
valkey-protocol(7) Array reply: a list of fields and their values stored in the hash, or an empty list when key does not exist.
so in RESP2 you're getting a flat array. field, value, field, value. that's the alternating thing we were just talking about π
π RESP3
valkey-protocol(7) Map reply: a map of fields and their values stored in the hash, or an empty list when key does not exist.
RESP3 said "let's make this a whole map actually" and honestly? ate. π
β¨ COMPLEXITY β¨
O(N) where N is the size of the hash.
translation: the bigger the hash, the more work it does. it's not out here doing magic, it's doing a lap around every single field. keep that in mind if your hash is, like, enormous π
β¨ ACL CATEGORIES β¨
@hash@read@slow
yep, @slow is in there and it's not being shady, it's just being honest β see that O(N) up above π«
β¨ HISTORY β¨
- Available since: 2.0.0 β yeah she's been here a minute, a true veteran of the game β
β¨ EXAMPLES β¨
watch and learn bestie, this is the whole flow:
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> HGETALL myhash
1) "field1"
2) "Hello"
3) "field2"
4) "World"
see how it goes "field1", "Hello", "field2", "World"? field, value, field, value β literally the alternating thing, right there in the wild. no cap π₯
heads up: that output is the RESP2 array vibe. if you're on RESP3 you'd get it as a map instead. same info, different outfit π
β¨ SEE ALSO β¨
the whole hash fam, go say hi:
hdel(3valkey), hexists(3valkey), hexpire(3valkey), hexpireat(3valkey), hexpiretime(3valkey), hget(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)
okay that's the whole page, you're officially educated π
this was Valkey 9.0.0, dated 2025-10-21 β go forth and HGETALL responsibly, bestie π¦β¨π
π¦ 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