w3resource

Redis Sets: SINTER

SINTER key1 [key2]

Redis SINTER command is used to return the members of the set resulting from the intersection of all the specified sets. Keys that do not exist are considered to be empty sets and if one of the keys being an empty set, the resulting set is also empty.

Syntax:

SINTER KEY KEY1..KEYN

Available since:

1.0.0.

Return Value:

Array reply, list with members of the resulting set.

Return Value Type:

Array

Example: Redis SINTER of two sets

127.0.0.1:6379> SADD mycolor1 R G B
(integer) 3
127.0.0.1:6379> SADD mycolor2 G B Y
(integer) 3
127.0.0.1:6379> SINTER mycolor1 mycolor2
1) "G"
2) "B"

Example: Redis SINTER of three sets

How is a sinter key1 key2 key3. 
mycolor1 = {R G B} 
mycolor2 = {G B Y} 
mycolor3 = {B W O} 
SINTER mycolor1 mycolor2 mycolor3 = {B} 
The number of key is not limited.

127.0.0.1:6379> SADD mycolor3 B W O
(integer) 3
127.0.0.1:6379> SINTER mycolor1 mycolor2 mycolor3
1) "B"


Follow us on Facebook and Twitter for latest update.