Redis SDIFFSTORE command stores the members of the set, resulting from the difference between the first set and all the successive sets, into a set specified in the command. If the destination already exists, it is overwritten.
Return Value
Integer reply, the number of elements in the resulting set.
Syntax
Following is the basic syntax of Redis SDIFFSTORE command.
redis 127.0.0.1:6379> SDIFFSTORE DESTINATION_KEY KEY1..KEYN
Example
redis 127.0.0.1:6379> SADD myset "hello" (integer) 1 redis 127.0.0.1:6379> SADD myset "foo" (integer) 1 redis 127.0.0.1:6379> SADD myset "bar" (integer) 1 redis 127.0.0.1:6379> SADD myset2 "hello" (integer) 1 redis 127.0.0.1:6379> SADD myset2 "world" (integer) 1 redis 127.0.0.1:6379> SDIFFSTORE destset myset myset2 (integer) 2 redis 127.0.0.1:6379> SMEMBERS destset 1) "foo" 2) "bar"