Redis命令-集合-sdiff

 

原文

http://redis.io/commands/sdiff

 

简介

Subtract multiple sets.

 

多个集合的差集。

 

语法

SDIFF key [key ...]

 

版本

Available since 1.0.0.

 

自1.0.0版本可用。

 

时间复杂度

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

 

O(N):N是所有给定集合中元素的总数。

 

描述

Returns the members of the set resulting from the difference between the first set and all the successive sets.

 

返回在第一个集合中存在,但是在后面的集合中都不存在的元素。

 

For example:

key1 = {a,b,c,d}
key2 = {c}
key3 = {a,c,e}
SDIFF key1 key2 key3 = {b,d}

 

Keys that do not exist are considered to be empty sets.

 

不存在的key被认为是空集合。

 

返回值

Array reply: list with members of the resulting set.

 

Array:结果集合的成员列表。

 

例子

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) "b"
2) "a"
redis>

 

你可能感兴趣的:(Redis)