Back to Redis

HGETALL

content/commands/hgetall.md

latest1.6 KB
Original Source

Returns all fields and values of the hash stored at key. In the returned value, every field name is followed by its value, so the length of the reply is twice the size of the hash.

Examples

{{< clients-example set="cmds_hash" step="hgetall" description="Foundational: Retrieve all fields and values from a hash using HGETALL (returns alternating field-value pairs, useful for loading entire hash data)" difficulty="beginner" >}} redis> HSET myhash field1 "Hello" (integer) 1 redis> HSET myhash field2 "World" (integer) 1 redis> HGETALL myhash

  1. "field1"
  2. "Hello"
  3. "field2"
  4. "World" {{< /clients-example >}}

Give these commands a try in the interactive console:

{{% redis-cli %}} HSET myhash field1 "Hello" HSET myhash field2 "World" HGETALL myhash {{% /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="hgetall-return-info" tab1="RESP2" tab2="RESP3" >}}

Array reply: a list of fields and their values, or an empty list when key does not exist.

-tab-sep-

Map reply: a map of fields and their values, or an empty list when key does not exist.

{{< /multitabs >}}