Redis Hmget Command

Redis Hash

The Redis Hmget command is used to return the values of one or more given fields in a hash table.

If the specified field does not exist in the hash table, a nil value is returned.

Syntax

The basic syntax of the redis Hmget command is as follows:

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

Available Versions

>= 2.0.0

Return Value

A table containing the associated values of multiple given fields, where the order of the table values is the same as the order in which the specified fields were requested.

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

Redis Hash

Other Extensions