HGETALL - Retrieve All Fields and Values from a Redis Hash

Feature thumb course thumb

In Redis, you can utilize the HGETALL command in order to retrive all of the fields and values from a specified hash. This operation returns an array that is double the size of the number of fields because the array is filled with both the fields and the values of each field. The order is that a field is followed by its respective value.

If the command is called on an empty or non existent set, it will return an empty array.

127.0.0.1:6379> HSET astros second_base 'Altuve'
(integer) 1
127.0.0.1:6379> HSET astros short_stop 'Correa'
(integer) 1
127.0.0.1:6379> HSET astros third_base 'Bregman'
(integer) 1
127.0.0.1:6379> HSET astros catcher 'Gattis'
(integer) 1
127.0.0.1:6379> HGETALL astros
1) "second_base"
2) "Altuve"
3) "short_stop"
4) "Correa"
5) "third_base"
6) "Bregman"
7) "catcher"
8) "Gattis"
127.0.0.1:6379> HGETALL rangers
(empty list or set)