Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Redis Hgetall Command

Redis Hgetall Command

Redis Hash

The Redis Hgetall command is used to return all fields and values in the hash.

In the return value, each field name is immediately followed by its value, so the length of the reply is twice the size of the hash.

Syntax

The basic syntax of the redis Hgetall command is as follows:



redis 127.0.0.1:6379> HGETALL KEY_NAME 

Available Version

= 2.0.0

Return Value

Returns the fields and values of the hash as a list. If key does not exist, returns an empty list.

Example



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"

redis> 

Redis Hash