Redis Sdiff Command
The Redis Sdiff command returns the difference between the first set and the other sets, which can also be considered as the elements unique to the first set. Non-existent set keys are treated as empty sets.
The result of the difference comes from the first FIRST_KEY, not from the later OTHER_KEY1, nor from the difference of the whole FIRST_KEY OTHER_KEY1..OTHER_KEYN.
Example:
key1 = {a,b,c,d}
key2 = {c}
key3 = {a,c,e}
SDIFF key1 key2 key3 = {b,d}
Syntax
The basic syntax of the redis Sdiff command is as follows:
redis 127.0.0.1:6379> SDIFF FIRST_KEY OTHER_KEY1..OTHER_KEYN
Available Versions
>= 1.0.0
Return Value
A list containing the members of the resulting difference.
Examples
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>
Other Extensions
Redis Set