MSET
MSET key value [key value ...]
- Group
- String
- Complexity
- O(N) for N keys
- Arity
- -3 (at least 3 words, counting the command name)
- Flags
- write
- Keys
- first 1, last final argument, step 2
- 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 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
Section titled “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
Section titled “Examples”127.0.0.1:6379> MSET user:1 "ada" user:2 "grace"OK127.0.0.1:6379> MGET user:1 user:21) "ada"2) "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.