# MSET

> Set several keys to string values in one step.

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

```
MSET key value [key value ...]
```

- Group: String
- Complexity: O(N) for N keys
- HotKV Cloud: all plans
- On-Premise: no license needed

`MSET` stores each `value` at its `key`, overwriting existing values of any
type and clearing their time to live, as [SET](https://docs.hotkv.com/commands/set/index.md) does. All keys
are written together: no client sees some of them set and others not yet. If
a key is named twice, the last value wins.

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

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Always | Simple string `OK` | Simple string `OK` |

An odd number of arguments after the command name is an
`ERR wrong number of arguments for 'mset' command` error.

## Examples

```
127.0.0.1:6379> MSET user:1 "ada" user:2 "grace"
OK
127.0.0.1:6379> MGET user:1 user:2
1) "ada"
2) "grace"
```

## Compatibility

Same as Redis 7 and Valkey 8.

## See also

[MGET](https://docs.hotkv.com/commands/mget/index.md), [MSETNX](https://docs.hotkv.com/commands/msetnx/index.md),
[MSETEX](https://docs.hotkv.com/commands/msetex/index.md), [SET](https://docs.hotkv.com/commands/set/index.md)