What's new in Valkey 9.0? Discover new features and improvements. Read the announcement.

HMGET

Returns the values of all fields in a hash.

Usage
HMGET key field ...
Complexity
O(N) where N is the number of fields being requested.
Since
2.0.0
ACL Categories
@fast, @hash, @read
Command flags
READONLY, FAST

Returns the values associated with the specified fields in the hash stored at key.

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.

127.0.0.1:6379> HSET myhash field1 "Hello"
(integer) 1
127.0.0.1:6379> HSET myhash field2 "World"
(integer) 1
127.0.0.1:6379> HMGET myhash field1 field2 nofield
1) "Hello"
2) "World"
3) (nil)

Replies

RESP2

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

RESP3

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