Redis - Hash Hmget Command


Advertisements

Redis HMGET command is used to get the values associated with the specified fields in the hash stored at the key. If the field does not exist in Redis hash, then a nil value is returned.

Return Value

Array reply, list of values associated with the given fields, in the same order as they are requested.

Syntax

Following is the basic syntax of Redis HMGET command.

redis 127.0.0.1:6379> HMGET KEY_NAME FIELD1...FIELDN 

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> HMGET myhash field1 field2 nofield 
1) "foo" 
2) "bar" 
3) (nil)
redis_hashes.htm
Advertisements