Redis Sets: SDIFFSTORE
SDIFFSTORE destination key1 [key2]
Redis SDIFFSTORE command store the members of the set, resulting from the difference between the first set and all the successive sets, into the specified key. If the specified key already exists, it is overwritten.
Syntax:
SDIFFSTORE DESTINATION_KEY KEY1..KEYN
Available since:
1.0.0.
Return Value:
Integer replies, the number of elements in the resulting set.
Save to obtain a new set of Difference
mycolor1 = {R G B}
mycolor2 = {G Y}
SDIFFSTORE dest_key mycolor1 mycolor2 = {R B}
Return Value Type:
Integer
Example: Redis SDIFFSTORE
127.0.0.1:6379> SADD mycolor1 R G B (integer) 3 127.0.0.1:6379> SADD mycolor2 G Y (integer) 2 127.0.0.1:6379> SDIFFSTORE dest_key mycolor1 mycolor2 (integer) 2 127.0.0.1:6379> SMEMBERS dest_key 1) "R" 2) "B"
Save obtain a set of three car set
How is sdiffstore destination_key source_key1 source_key2 source_key3.
mycolor1 = {R G B}
mycolor2 = {G Y}
mycolor3 = {B P}
SDIFFSTORE dest_key mycolor1 mycolor2 mycolor3 = {R}
There is no limit to the number of the key.
127.0.0.1:6379> SADD mycolor3 B P (integer) 2 127.0.0.1:6379> SDIFFSTORE dest_key mycolor1 mycolor2 mycolor3 (integer) 1 127.0.0.1:6379> SMEMBERS dest_key 1) "R"
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics