Back to Redis

HGET

content/commands/hget.md

latest1.6 KB
Original Source

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

Examples

{{< clients-example set="cmds_hash" step="hget" description="Foundational: Retrieve a single field value from a hash using HGET (returns nil if field or key doesn't exist)" difficulty="beginner" >}}

HSET myhash field1 "foo" (integer) 1 HGET myhash field1 "foo" HGET myhash field2 (nil) {{< /clients-example >}}

Give these commands a try in the interactive console:

{{% redis-cli %}} HSET myhash field1 "foo" HGET myhash field1 HGET myhash field2 {{% /redis-cli %}}

Redis Software and Redis Cloud compatibility

| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | |

Return information

{{< multitabs id="hget-return-info" tab1="RESP2" tab2="RESP3" >}}

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.

-tab-sep-

One of the following:

{{< /multitabs >}}