Redis Sdiff 命令返回给定集合之间的差集。不存在的集合 key 将视为空集。
redis Sdiff 命令基本语法如下:
redis 127.0.0.1:6379> SDIFF FIRST_KEY OTHER_KEY1..OTHER_KEYN
>= 1.0.0
包含差集成员的列表。
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> SDIFF myset myset2 1) "foo" 2) "bar"