Latest web development tutorials

Redis Sdiffstore command

Redis set (Set)

Redis Sdiffstore given command set difference between the sets stored in the specified collection. If the specified collection of key already exists, it is overwritten.

grammar

redis Sdiffstore basic command syntax 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 result set.

Examples

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"

Redis set (Set)