MSET(3valkey)

πŸ“¦
version 9.0.6 Β· 2 versions
, in fedora 44

πŸ’– MSET β€” the manual page, but make it cute πŸ’–

okay bestie, this is the mset page from the Valkey Command Manual and it's lowkey one of the most useful things in the whole book. it's giving "set a bunch of keys all at once, atomically, no drama." let's get into it 🫢


✨ NAME ✨

mset β€” atomically creates or modifies the string values of one or more keys.

like, atomically. all at once. the whole group or nothing shows up mid-way. periodt. πŸ’…


🌸 SYNOPSIS 🌸

MSET key value [key value ...]

so you just keep pairing them up, bestie: a key, then its value, then another key, then its value, forever until you're done. it's a little conga line of key-value pairs. πŸŽ€


πŸ’œ DESCRIPTION πŸ’œ

sets the given keys to their respective values. MSET replaces existing values with new values, just as regular SET. and if you do NOT want to stomp on stuff that's already there? go look at MSETNX instead, she's the one who refuses to overwrite. πŸ™ˆ

MSET is atomic, so all the given keys get set at once. it is not possible for clients to see that some of the keys were updated while others were unchanged. no half-finished glow-up, no in-between state, nobody catching you mid-outfit-change. it's all or all. πŸ”₯


⭐ REPLY ⭐

valkey-protocol(7) β€” simple string reply: it's always OK because MSET can't fail. she literally cannot miss. ate and left no crumbs. πŸ‘‘


πŸ¦‹ COMPLEXITY πŸ¦‹

O(N) where N is the number of keys to set.

so yeah, more keys = more work, obviously. math is math. 😌


πŸŽ€ ACL CATEGORIES πŸŽ€

  • @slow
  • @string
  • @write

three little tags so your ACL rules know what kind of girl she is. 🌈


πŸ’… HISTORY πŸ’…

  • Available since: 1.0.1

an icon. been here since basically forever. no cap.


✨ EXAMPLES ✨

127.0.0.1:6379> MSET key1 "Hello" key2 "World"
OK
127.0.0.1:6379> GET key1
"Hello"
127.0.0.1:6379> GET key2
"World"

see?? two keys, two values, one OK, and then GET pulls each one back exactly how you left it. chef's kiss. πŸ“


πŸ‘‘ SEE ALSO πŸ‘‘

the whole string-value friend group. go say hi. 🧚


ok that's the whole page, every flag, every note, every reference, nothing skipped, we don't do that here πŸ’–

and that's a wrap, bestie!! this one's from Valkey 9.0.0, dated 2025-10-21 β€” mwah, love u, go set some keys atomically πŸ’œπŸ«Άβœ¨

πŸ“¦ where this page comes from