w3resource

Redis Hash: HMGET

HMGET key field1 [field2]

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

Syntax:

HMGET KEY_NAME FIELD1...FIELDN   

Available since

2.0.0.

Return Value

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

Return Value Type

Integer

Example: Redis HMGET

127.0.0.1:6379> HSET langhash lang1 "PHP"
(integer) 1
127.0.0.1:6379> HSET langhash lang2 "Javascript"
(integer) 1
127.0.0.1:6379> HSET langhash lang3 "Python"
(integer) 1
127.0.0.1:6379> HMGET langhash lang1 lang2 lang3 lang4
1) "PHP"
2) "Javascript"
3) "Python"
4) (nil)

Example: Redis HMGET another example

127.0.0.1:6379> HMSET user-y email [email protected] language English gender Male
OK
127.0.0.1:6379> HMGET user-y email language gender
1) "[email protected]"
2) "English"
3) "Male"

Previous: HLEN
Next: HMSET



Follow us on Facebook and Twitter for latest update.