SDIFF key [key ...]
返回一个集合与给定集合的差集的元素.
举例:
key1 = {a,b,c,d}
key2 = {c}
key3 = {a,c,e}
SDIFF key1 key2 key3 = {b,d}
不存在的key认为是空集.
返回值
array-reply:结果集的元素.
举例
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>
相关参考链接
Sets相关命令:
命令组 | 命令 |
Sets(集合) | SADD; SCARD; SDIFF; SDIFFSTORE; SINTER; SINTERSTORE; SISMEMBER; SMEMBERS; SMOVE; SPOP; SRANDMEMBER; SREM; SSCAN; SUNION; SUNIONSTORE; |
全部命令组:Keys(键)、Strings(字符串)、Hashes(哈希表)、Lists(列表)、Sets(集合)、Sorted Sets(有序集合)、Pub/Sub(发布/订阅)、Scripting(脚本)、Server(服务器)、Transactions(事物),Geo(地理位置)、Cluster(集群)、Connection(连接)、Streams(流)、HyperLogLog。
回到总目录:Redis命令参考手册(总目录)