Easy Tutorial
❮ Sets Sdiff Sorted Sets Zcard ❯

Redis Hmget Command

Redis Hashes

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

If the specified fields do not exist in the hash table, a nil value is returned.

Syntax

The basic syntax for 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 list containing the values associated with the given fields, in the same order as the requested fields.

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

❮ Sets Sdiff Sorted Sets Zcard ❯