HMGET key field [field ...]
HMGET command returns the values associated with the specified fields in the hash stored at key.
Note: For every field that does not exist in the hash, a nil value is returned. Because non-existing keys are treated as empty hashes, running HMGET against a non-existing key will return a list of nil values.
TIME COMPLEXITY O(N) where N is the number of fields being requested.
RETURN VALUE Multi-bulk reply: list of values associated with the given fields, in the same order as they are requested.
Syntax:
HMGET KEY_NAME FIELD_NAME1 FIELD_NAME2 ... FIELD_NAMEN
Example 1: When all fields are present.
redis:6379> HMGET myhash field field21) "200"2) "200"
Output
1) "200"
2) "200"
Example 2: When one or more fields are not present.
redis:6379> HMGET myhash field field2 field31) "200"2) "200"3) (nil)
Output
1) "200"
2) "200"
3) (nil)
No comments:
Post a Comment