Redis command-collection-sdiffstore

 

original

http://redis.io/commands/sdiffstore

 

Introduction

Subtract multiple sets and store the resulting set in a key.

 

The difference of multiple sets, and store the result set to a key.

 

grammar

SDIFFSTORE destination key [key ...]

 

Version

Available since 1.0.0.

 

Available since version 1.0.0.

 

time complexity

Time complexity: O(N) where N is the total number of elements in all given sets.

 

O(N): N is the total number of elements in all given sets.

 

describe

This command is equal to SDIFF, but instead of returning the resulting set, it is stored in destination.

 

This command is equivalent to SDIFF, but instead of returning the result set, it is stored to another key.

 

If destination already exists, it is overwritten.

 

If destination already exists, it will be overwritten.

 

return value

Integer reply: the number of elements in the resulting set.

Integer: The number of elements in the resulting set.

 

example

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>  SDIFFSTORE key key1 key2
(integer) 2
redis>  SMEMBERS key
1) "b"
2) "a"
redis>

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326983644&siteId=291194637