SINTERSTORE(3valkey)

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

πŸ’– SINTERSTORE πŸ’–

okay bestie, welcome to the sinterstore page from the Valkey Command Manual, section 3valkey. she's a set-ops girlie and she's about to store some vibes, not just show them off. ✨


🌸 NAME 🌸

sinterstore β€” Stores the intersect of multiple sets in a key.

like, it finds the overlap and then keeps it. main character energy fr. πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

SINTERSTORE destination key [key...]

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the tea: this command is equal to SINTER, except instead of just returning the resulting set to you like a lil show-off, it stores it in destination. the results get written down. committed. periodt. πŸ’…

and if destination already exists? it gets overwritten. no warning, no mercy, she just replaces whatever was there. ngl that's kind of iconic of her but also watch out. 😭


πŸ’œ REPLY πŸ’œ

valkey-protocol(7) Integer reply: the number of elements in the resulting set.

so you get back a lil number telling you how many besties made it into the intersection. 🫢


🌈 COMPLEXITY 🌈

O(N*M) worst case, where N is the cardinality of the smallest set and M is the number of sets.

translation: she finds the smallest set and uses it as the starting point, which is lowkey smart of her. πŸ’€


⭐ ACL CATEGORIES ⭐

  • @set
  • @slow
  • @write

🧚 HISTORY 🧚

  • Available since: 1.0.0 β€” she's an OG, been here since the very beginning. πŸ‘‘

πŸ“ EXAMPLES πŸ“

watch her 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> SINTERSTORE key key1 key2
(integer) 1
127.0.0.1:6379> SMEMBERS key
1) "c"

so key1 is a, b, c and key2 is c, d, e. the only one they have in common? "c". and boom, key now holds exactly that one lil legend. the reply is (integer) 1 because one element made it through. slay. πŸ’–


πŸŽ€ SEE ALSO πŸŽ€


okay that's the whole page bestie, you're officially a SINTERSTORE expert now, no cap πŸ’…βœ¨

this lil masterpiece is from Valkey version 9.0.0, dated 2025-10-21. go forth and intersect, queen. πŸ‘‘πŸ¦‹

πŸ“¦ where this page comes from