Redis Sets: SINTERSTORE
SINTERSTORE destination key1 [key2]
Redis SINTERSTORE command is used to store the members of the set resulting from the intersection of all the specified sets in a specific key. 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:
SINTERSTORE DESTINATION_KEY KEY KEY1..KEYN
Available since:
1.0.0.
Return Value:
Integer replies the number of elements in the resulting set.
Return Value Type:
Integer
Example: Redis SINTERSTORE of two sets
mycolor1 = {R G B}
mycolor2 = {G B Y}
SINTERSTORE dest_key mycolor1 mycolor2 = {G B}
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> SINTERSTORE dest_key mycolor1 mycolor2 (integer) 2 127.0.0.1:6379> SMEMBERS dest_key 1) "G" 2) "B"
Example: Redis SINTERSTORE of three sets
mycolor1 = {R G B}
mycolor2 = {G B Y}
mycolor3 = {B W O}
SINTERSTORE dest_key myset1 myset2 myset3 = {B}
127.0.0.1:6379> SADD mycolor3 B W O (integer) 3 127.0.0.1:6379> SINTERSTORE dest_key mycolor1 mycolor2 mycolor3 (integer) 1 127.0.0.1:6379> SMEMBERS dest_key 1) "B"
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics