SDIFF key [key ...]

Redis SDIFF 命令返回第一个集合与其他集合之间的差异,也可以认为说第一个集合中独有的元素。不存在的集合 key 将视为空集。

For example:

key1 = {a,b,c,d}
key2 = {c}
key3 = {a,c,e}
SDIFF key1 key2 key3 = {b,d}

Keys that do not exist are considered to be empty sets.

*返回值

数组: list with members of the resulting set.

*例子

redis>  SADD key1 "a"
(integer) 1
redis>  SADD key1 "b"
(integer) 1
redis>  SADD key1 "c"
(integer) 1
redis>  SADD key2 "c"
(integer) 1
redis>  SADD key2 "d"
(integer) 1
redis>  SADD key2 "e"
(integer) 1
redis>  SDIFF key1 key2
1) "a"
2) "b"
redis>