sDiffStore

PHP Redis

sDiffStore

Description

Performs the same action as sDiff, but stores the result in the first key

与sDiff函数功能一直,只是结果为一个新的SET集合,存储到dstkey。

Parameters

Key: dstkey, the key to store the diff into.

Key:存储结果的SET集合KEY

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

参与操作的SET集合

Return value

INTEGER: The cardinality of the resulting set, or FALSE in case of a missing key.

返回整数:为结果集的个数。

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->sDiffStore('dst', 's0', 's1', 's2'));
var_dump($redis->sMembers('dst'));

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

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