Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

SINTER

Last updated
SINTER key [key ...]
Group
Set
Complexity
O(N*M) worst case, where N is the size of the smallest set and M is the number of sets
Arity
-2 (at least 2 words, counting the command name)
Flags
read-only
Keys
first 1, last final argument, step 1
HotKV Cloud
All plans
On-Premise
no license needed

SINTER returns the intersection of the given sets: the members that are in all of them. A missing key counts as an empty set, so if any key is missing the result is empty. To count the intersection without returning it, use SINTERCARD; to store it, use SINTERSTORE.

Case RESP2 RESP3
Success Array of bulk strings (empty if there is no common member) Set of bulk strings

SINTER replies with a WRONGTYPE error if any of the keys holds a value that is not a set, even when another key is missing.

127.0.0.1:6379> SADD a "x" "y" "z"
(integer) 3
127.0.0.1:6379> SADD b "y" "z" "w"
(integer) 3
127.0.0.1:6379> SINTER a b
1) "y"
2) "z"
127.0.0.1:6379> SINTER a nosuchkey
(empty array)

Same as Redis 7.4 and Valkey 8.

SINTERSTORE, SINTERCARD, SUNION, SDIFF, ZINTER