HGET(3valkey)

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

πŸ’– HGET β€” the 3valkey era πŸ’–

okay bestie, welcome to the Valkey Command Manual section 3valkey πŸ¦‹ this one's about HGET and it's honestly so simple it's iconic.


✨ NAME ✨

hget β€” returns the value of a field in a hash. that's it. that's the whole job. πŸŽ€


🌸 SYNOPSIS 🌸

HGET key field

two arguments. no drama. we love a low-maintenance command. πŸ’…


πŸ’œ DESCRIPTION πŸ’œ

so like, you got a hash chillin' at some key, right? HGET returns the value associated with field inside that hash. one field, one value, boom, done, main character energy. πŸ‘‘


🫢 REPLY 🫢

RESP2

you're gonna get one of these back:

  • valkey-protocol(7) Bulk string reply β€” the value associated with the field. yay! πŸŽ‰
  • valkey-protocol(7) Nil reply β€” if the field isn't present in the hash, or the key doesn't exist at all. 😭 (no cap, it's just nil, don't panic)

RESP3

same vibe, slightly different flavor of nothing:

  • valkey-protocol(7) Bulk string reply β€” the value associated with the field. still slaying. ✨
  • valkey-protocol(7) Null reply β€” if the field isn't present in the hash, or the key doesn't exist. same emptiness, new protocol. πŸ’€

πŸ”₯ COMPLEXITY πŸ”₯

O(1)

constant time, bestie. it does not care how big your hash is. it's giving efficiency. ⭐


πŸ‘‘ ACL CATEGORIES πŸ‘‘

@fast @hash @read

fast, hash-related, and read-only. the holy trinity of "yes you're allowed." 🌈


🌸 HISTORY 🌸

  • Available since: 2.0.0 β€” an elder. a legend. been here since forever and still ate. πŸ’…

πŸŽ€ EXAMPLES πŸŽ€

127.0.0.1:6379> HSET myhash field1 "foo"
(integer) 1
127.0.0.1:6379> HGET myhash field1
"foo"
127.0.0.1:6379> HGET myhash field2
(nil)

see how field1 came back with "foo" all pretty ✨ and field2 just said (nil)? yeah. that's the whole thing. no notes. πŸ™ˆ


🧚 SEE ALSO 🧚

your hash besties, all of them, no one left behind: hdel(3valkey), hexists(3valkey), hexpire(3valkey), hexpireat(3valkey), hexpiretime(3valkey), hgetall(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 page!! this is version 9.0.0, dated 2025-10-21, and it's from the 3valkey manual β€” go get that field, bestie, you got this πŸ«ΆπŸ’–βœ¨

πŸ“¦ where this page comes from