sDiff

PHP Redis

sDiff

Description

Performs the difference between N sets and returns it.

执行差集操作在N个不同的SET容器之间,并返回结果。这个操作取得结果是第一个SET相对于其他参与计算的SET集合的差集。(Result = SET0 - (SET1 UNION SET2 UNION ....SET N))

Parameters

Keys: key1, key2, ... , keyN: Any number of keys corresponding to sets in redis.

Return value

Array of strings: The difference of the first set will all the others.

返回数组,返回的是第一个SET集合相对于其他集合的差集(first set - (N sets)) 

返回数组:第一个SET集合的补

Example
$redis->delete('s0', 's1', 's2');

$redis->sAdd('s0', '1');
$redis->sAdd('s0', '2');
$redis->sAdd('s0', '3');
$redis->sAdd('s0', '4');

$redis->sAdd('s1', '1');
$redis->sAdd('s2', '3');

var_dump($redis->sDiff('s0', 's1', 's2'));

Return value: all elements of s0 that are neither in s1 nor in s2.

array(2) {
  [0]=>
  string(1) "4"
  [1]=>
  string(1) "2"
}