hmget.3valkey - Man Page

Returns the values of all fields in a hash.

Synopsis

HMGET key field [field...]

Description

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)

Reply

valkey-protocol(7) Array reply: a list of values associated with the given fields, in the same order as they are requested.

Complexity

O(N) where N is the number of fields being requested.

Acl Categories

@fast @hash @read

History

See Also

hdel(3valkey), hexists(3valkey), hget(3valkey), hgetall(3valkey), hincrby(3valkey), hincrbyfloat(3valkey), hkeys(3valkey), hlen(3valkey), hrandfield(3valkey), hscan(3valkey), hset(3valkey), hsetnx(3valkey), hstrlen(3valkey), hvals(3valkey)

Info

2024-09-23 8.0.0 Valkey Command Manual