HGETALL command in redis

HGETALL key

HGETALL returns both the fields and values in the form of field1, value1, field2, value2, ..., fieldN, valueN.

TIME COMPLEXITY: O(N), where N is the total number of entries

RETURN VALUE: Multi Bulk Reply

Syntax:

HGETALL KEY_NAME

Example 1: When the ley is present

redis:6379> HGETALL myhash
1) "field"
2) "100"
3) "field2"
4) "300"
5) "field1"
6) "200"

Output

1) "field"

2) "100"

3) "field2"

4) "300"

5) "field1"

6) "200"


Example 2: When the key is not present

redis:6379> HGETALL hello
(empty array)

Output

empty array


No comments:

Post a Comment