SUNIONSTORE(3valkey)

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

πŸ’– SUNIONSTORE πŸ’–

okay bestie, welcome to SUNIONSTORE β€” a page straight out of the Valkey Command Manual (yes, the whole SUNIONSTORE(3valkey) moment, we're here, we're thriving 🫢).


✨ NAME ✨

sunionstore β€” stores the union of multiple sets in a key. that's it. that's the whole vibe. πŸ¦‹


🌸 SYNOPSIS 🌸

SUNIONSTORE destination key [key...]

πŸ’… DESCRIPTION πŸ’…

so listen. this command is literally equal to SUNION, no cap β€” but instead of handing you back the resulting set like a little gift, it stores it in destination. it's giving "i made you a playlist and saved it to your library instead of just texting you the songs." main character energy, honestly. πŸ‘‘

and if destination already exists? it gets overwritten. not merged, not negotiated with, not asked politely. just gone, replaced, slay. πŸ’€


πŸŽ€ REPLY πŸŽ€

valkey-protocol(7) Integer reply: the number of elements in the resulting set. just a cute little integer, telling you how many things ended up in there. ⭐


πŸ”₯ COMPLEXITY πŸ”₯

O(N) where N is the total number of elements in all given sets.


πŸ‘‘ ACL CATEGORIES πŸ‘‘

@set @slow @write


🌈 HISTORY 🌈

  • Available since: 1.0.0

an icon since day one, fr fr. this command has been serving since 1.0.0. πŸ’œ


🧚 EXAMPLES 🧚

watch me cook πŸ“

127.0.0.1:6379> SADD key1 "a"
(integer) 1
127.0.0.1:6379> SADD key1 "b"
(integer) 1
127.0.0.1:6379> SADD key1 "c"
(integer) 1
127.0.0.1:6379> SADD key2 "c"
(integer) 1
127.0.0.1:6379> SADD key2 "d"
(integer) 1
127.0.0.1:6379> SADD key2 "e"
(integer) 1
127.0.0.1:6379> SUNIONSTORE key key1 key2
(integer) 5
127.0.0.1:6379> SMEMBERS key
1) "a"
2) "b"
3) "c"
4) "d"
5) "e"

okay so notice how "c" was in both key1 and key2, and it showed up exactly once? that's the union doing its thing, no duplicates, we love a tidy queen. ✨ and the reply was (integer) 5 because five elements made it into key. ate. πŸ’…


πŸ¦‹ SEE ALSO πŸ¦‹


bestie if you made it this far you're officially a set-theory girlie. go forth and union everything. πŸ’–

version 9.0.0 Β· dated 2025-10-21 Β· sunionstore(3valkey) β€” that's a wrap, mwah, love u, bye πŸŽ€πŸ«Άβœ¨

πŸ“¦ where this page comes from