Redis Sdiffstore Command
The Redis Sdiffstore command stores the difference between the given sets in the specified set. If the specified set key already exists, it will be overwritten.
Syntax
The basic syntax for the redis Sdiffstore command is as follows:
redis 127.0.0.1:6379> SDIFFSTORE DESTINATION_KEY KEY1..KEYN
Available Versions
= 1.0.0
Return Value
The number of elements in the resulting set.
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"