# MGET

> Return the string values of several keys in one call.

URL: https://docs.hotkv.com/commands/mget/

```
MGET key [key ...]
```

- Group: String
- Complexity: O(N) for N keys
- 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](https://docs.hotkv.com/commands/mset/index.md) 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

| 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

```
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"
```

## Compatibility

Same as Redis 7 and Valkey 8.

## See also

[MSET](https://docs.hotkv.com/commands/mset/index.md), [GET](https://docs.hotkv.com/commands/get/index.md),
[MSETNX](https://docs.hotkv.com/commands/msetnx/index.md)