HMGET(3valkey)
๐ HMGET ๐
okay bestie so this is a page from the Valkey Command Manual โ section 3valkey โ and today's main character is hmget(3valkey). yes it's a whole manual page for one lil command and honestly? it deserves it. ๐
โจ NAME โจ
hmget โ grabs the values of all the fields in a hash. all of them. no cap. ๐ซถ
๐ธ SYNOPSIS ๐ธ
HMGET key field [field...]
๐ฆ DESCRIPTION ๐ฆ
So basically, HMGET returns the values that are chillin' with the specified fields inside the hash that lives at key. that's it. that's the whole vibe. ๐
And here's the tea: if a field doesn't exist in the hash, you get a nil value back for it. no drama, no error, just nil. and because a key that doesn't exist at all is treated like an empty hash (iconic behavior honestly), running HMGET against a key that isn't even there will hand you back a whole list of nil values. every single one. it's giving "empty vibes only". ๐ณ๏ธโจ
lowkey the best way to see it is just... watching it happen:
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> HMGET myhash field1 field2 nofield
1) "Hello"
2) "World"
3) (nil)
see how nofield just... showed up as (nil)? yeah. that's the move. ๐ซ
๐ REPLY ๐
valkey-protocol(7) Array reply: a list of values associated with the given fields, in the same order as they are requested. order matters bestie, do not come for the ordering. ๐ฅ
๐ COMPLEXITY ๐
O(N) where N is the number of fields being requested. so the more fields you ask for, the more work it does. math is math. ๐งฎ
๐ ACL CATEGORIES ๐
@fast@hash@read
โญ HISTORY โญ
- Available since: 2.0.0 โ a true OG, been here since forever, main character energy from day one. ๐ฐ๏ธ๐
๐ SEE ALSO ๐
go read these too, they're all in the same friend group:
hdel(3valkey)hexists(3valkey)hexpire(3valkey)hexpireat(3valkey)hexpiretime(3valkey)hget(3valkey)hgetall(3valkey)hgetex(3valkey)hincrby(3valkey)hincrbyfloat(3valkey)hkeys(3valkey)hlen(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 version 9.0.0, dated 2025-10-21, and it's the HMGET(3valkey) manual page โ go forth and fetch those field values, you absolute legend. ๐โจ๐ฆ
๐ฆ 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