English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The Redis Sdiff command returns the difference between the first set and other sets, which can also be said to be the unique elements in the first set. Non-existing set key will be treated as an empty set.
The result of the difference set comes from the FIRST_KEY in front, not the OTHER_KEY behind1It is neither the entire FIRST_KEY OTHER_KEY1..OTHER_KEYN of the difference set.
Example:
key1 = {a,b,c,d} key2 = {c} key3 = {a,c,e} SDIFF key1 key2 key3 = {b,d}
Basic syntax of the redis Sdiff command is as follows:
redis 127.0.0.1:6379> SDIFF FIRST_KEY OTHER_KEY1..OTHER_KEYN
>= 1.0.0
List containing the members of the difference 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>