Redis – Hash Hgetall Command

  • Post author:
  • Post category:Redis
  • Post comments:0 Comments

Redis HGETALL command is used to get all the fields and values of the hash stored at the 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.

Return Value

Array reply, list of fields and their values stored in the hash, or an empty list when the key does not exist.

Syntax

Following is the basic syntax of Redis HGETALL command.

redis 127.0.0.1:6379> HGETALL KEY_NAME 

Example

redis 127.0.0.1:6379> HSET myhash field1 "foo" 
(integer) 1 
redis 127.0.0.1:6379> HSET myhash field2 "bar" 
(integer) 1 
redis 127.0.0.1:6379> HGETALL myhash 
1) "field1" 
2) "foo" 
3) "field2" 
4) "bar"

Leave a Reply