What's new in Valkey 9.0? Discover new features and improvements. Read the announcement.

HGET

Returns the value of a field in a hash.

Usage
HGET key field
Complexity
O(1)
Since
2.0.0
ACL Categories
@fast, @hash, @read
Command flags
READONLY, FAST

Returns the value associated with field in the hash stored at key.

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)

Replies

RESP2

One of the following:

  • Bulk string reply: The value associated with the field.
  • Nil reply: If the field is not present in the hash or key does not exist.

RESP3

One of the following: