HGETALL(3valkey)

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

πŸ’– 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