English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Redis Sdiffstore Command

Redis Sets (Set)

The Redis Sdiffstore command stores the difference set between the given sets in the specified set. If the specified set key already exists, it will be overwritten.

Syntax

The basic syntax of the redis Sdiffstore command is as follows:

redis 127.0.0.1:6379> SDIFFSTORE DESTINATION_KEY KEY1..KEYN

Available Version

>= 1.0.0

Return Value

Number of elements in the result set.

Online Examples

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> SDIFFSTORE destset myset myset2
(integer) 2
redis 127.0.0.1:6379> SMEMBERS destset
1) "foo"
2) "bar"

Redis Sets (Set)