MGET
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.
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| Always | Array with one element per key: a bulk string, or a nil bulk string | Array of bulk strings and nulls |
Examples
Section titled “Examples”127.0.0.1:6379> MSET user:1 "ada" user:2 "grace"OK127.0.0.1:6379> MGET user:1 missing user:21) "ada"2) (nil)3) "grace"Compatibility
Section titled “Compatibility”Same as Redis 7 and Valkey 8.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.