Latest web development tutorials

Redis Hgetall command

Redis hash (Hash)

Redis Hgetall command returns a hash table, all the fields and values.

In value in return, followed by the name of each field (field name) followed by the value of the field (value), so the return value is twice the length of the hash table size.

grammar

redis Hgetall basic command syntax is as follows:

redis 127.0.0.1:6379> HGETALL KEY_NAME 

Available versions

> = 2.0.0

return value

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

Examples

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) "Hello"
3) "field2"
4) "World"

Redis hash (Hash)