The Redis SINTER command returns the members of the set resulting from the intersection of all the given sets. Keys that do not exist are considered to be empty sets. With one of the keys being an empty set, the resulting set is also empty (since set intersection with an empty set always results in an empty set).

For example:

1
2
3
4
key1 = {a,b,c,d}
key2 = {c}
key3 = {a,c,e}
SINTER key1 key2 key3 = {c}

Syntax

The basic syntax of the SINTER command is as follows:

1
SINTER key [key ...]

Available Since

Redis version >= 1.0.0

Time Complexity

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

ACL Categories

@read, @set, @slow

Return Value

Returns a set with the members of the resulting set.

Example

1
2
3
4
5
6
7
8
9
127.0.0.1:6379> SADD key1 a b c d
(integer) 4
127.0.0.1:6379> SADD key2 c
(integer) 1
127.0.0.1:6379> SADD key3 a c e
(integer) 3
127.0.0.1:6379> SINTER key1 key2 key3
1) "c"
127.0.0.1:6379>