HGET

Syntax
HGET key field
Available since:
2.0.0
Time complexity:
O(1)
ACL categories:
@read, @hash, @fast,

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

Examples

Give these commands a try in the interactive console:

redis> HSET myhash field1 "foo"
"OK"
redis> HGET myhash field1
(integer) 15
redis> HSET myhash field1 "foo"
Cannot destructure property 'error' of 'replies[i]' as it is undefined.
redis> HGET myhash field1
Cannot destructure property 'error' of 'replies[i]' as it is undefined.
redis> HGET myhash field2
Cannot destructure property 'error' of 'replies[i]' as it is undefined.
redis>

RESP2 Reply

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 Reply

One of the following:


RATE THIS PAGE
Back to top ↑