/** * Performs the same action as sUnion, but stores the result in the first key * * @param string $dstKey the key to store the diff into. * @param array $keys * * @return int The cardinality of the resulting set, or FALSE in case of a missing key. * @link http://redis.io/commands/sunionstore * @example * <pre> * $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->sUnionStore('dst', array('s0', 's1', 's2'))); * var_dump($redis->sMembers('dst')); * //int(4) * //array(4) { * // [0]=> * // string(1) "3" * // [1]=> * // string(1) "4" * // [2]=> * // string(1) "1" * // [3]=> * // string(1) "2" * //} * </pre> */ public function sUnionStore($dstKey, array $keys) { try { return $this->client->sUnionStore($dstKey, $keys); } catch (Exception $e) { return $this->handleException($e, __FUNCTION__, func_get_args()); } }
/** * Performs the same action as sUnion, but stores the result in the first key * * @param string $dstKey the key to store the diff into. * @param array $keys * * @return int The cardinality of the resulting set, or FALSE in case of a missing key. * @link http://redis.io/commands/sunionstore * @example * <pre> * $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->sUnionStore('dst', array('s0', 's1', 's2'))); * var_dump($redis->sMembers('dst')); * //int(4) * //array(4) { * // [0]=> * // string(1) "3" * // [1]=> * // string(1) "4" * // [2]=> * // string(1) "1" * // [3]=> * // string(1) "2" * //} * </pre> */ public function sUnionStore($dstKey, array $keys) { $this->appendToLog('SUNIONSTORE ' . $dstKey . ' ' . implode(' ', $keys)); return $this->client->sUnionStore($dstKey, $keys); }