sUnion 命令/方法/函数

Performs the union between N sets and returns it.

执行一个并集操作在N个SET容器之间,并返回结果。


Parameters

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


Return value

Array of strings: The union of all these sets.

返回一个数组


Example

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


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

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

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

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

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

$redis->sAdd('s2', '4');


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


Return value: all elements that are either in s0 or in s1 or in s2.

array(4) {

  [0]=>

  string(1) "3"

  [1]=>

  string(1) "4"

  [2]=>

  string(1) "1"

  [3]=>

  string(1) "2"

}