Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

MGET

Last updated
MGET key [key ...]
Group
String
Complexity
O(N) for N keys
Arity
-2 (at least 2 words, counting the command name)
Flags
read-only, fast
Keys
first 1, last final argument, step 1
HotKV Cloud
All plans
On-Premise
no license needed

MGET returns the values of all the given keys, in the order you named them. A key that does not exist, or that holds a value that is not a string, gives a nil in its place instead of an error. All keys are read at the same moment, so an MSET running at the same time is seen either whole or not at all.

In a cluster, all keys must hash to the same slot.

Case RESP2 RESP3
Always Array with one element per key: a bulk string, or a nil bulk string Array of bulk strings and nulls
127.0.0.1:6379> MSET user:1 "ada" user:2 "grace"
OK
127.0.0.1:6379> MGET user:1 missing user:2
1) "ada"
2) (nil)
3) "grace"

Same as Redis 7 and Valkey 8.

MSET, GET, MSETNX