Пример #1
0
 /**
  * Creates an intersection of sorted sets given in second argument.
  * The result of the union will be stored in the sorted set defined by the first argument.
  * The third optional argument defines weights to apply to the sorted sets in input.
  * In this case, the weights will be multiplied by the score of each element in the sorted set
  * before applying the aggregation. The forth argument defines the AGGREGATE option which
  * specify how the results of the union are aggregated.
  *
  * @param string $output
  * @param array $zSetKeys
  * @param array $weights optional
  * @param string $aggregateFunction Either "SUM", "MIN", or "MAX": defines the behaviour to use on
  * duplicate entries during the zInter. optional, defaults to SUM
  *
  * @return int The number of values in the new sorted set.
  * @link http://redis.io/commands/zinterstore
  * @example
  * <pre>
  * $redis->delete('k1');
  * $redis->delete('k2');
  * $redis->delete('k3');
  * $redis->delete('ko1');
  * $redis->delete('ko2');
  * $redis->delete('ko3');
  * $redis->delete('ko4');
  * $redis->zAdd('k1', 0, 'val0');
  * $redis->zAdd('k1', 1, 'val1');
  * $redis->zAdd('k1', 3, 'val3');
  * $redis->zAdd('k2', 2, 'val1');
  * $redis->zAdd('k2', 3, 'val3');
  * $redis->zInter('ko1', array('k1', 'k2')); // 2, 'ko1' => array('val1', 'val3')
  * $redis->zInter('ko2', array('k1', 'k2'), array(1, 1)); // 2, 'ko2' => array('val1', 'val3')
  * // Weighted zInter
  * $redis->zInter('ko3', array('k1', 'k2'), array(1, 5), 'min'); // 2, 'ko3' => array('val1', 'val3')
  * $redis->zInter('ko4', array('k1', 'k2'), array(1, 5), 'max'); // 2, 'ko4' => array('val3', 'val1')
  * </pre>
  */
 public function zInter($output, array $zSetKeys, array $weights = array(), $aggregateFunction = 'SUM')
 {
     try {
         return $this->client->zInter($output, $zSetKeys, $weights, $aggregateFunction);
     } catch (Exception $e) {
         return $this->handleException($e, __FUNCTION__, func_get_args());
     }
 }
Пример #2
0
 /**
  * Creates an intersection of sorted sets given in second argument.
  * The result of the union will be stored in the sorted set defined by the first argument.
  * The third optional argument defines weights to apply to the sorted sets in input.
  * In this case, the weights will be multiplied by the score of each element in the sorted set
  * before applying the aggregation. The forth argument defines the AGGREGATE option which
  * specify how the results of the union are aggregated.
  *
  * @param string $output
  * @param array $zSetKeys
  * @param array $weights optional
  * @param string $aggregateFunction Either "SUM", "MIN", or "MAX": defines the behaviour to use on
  * duplicate entries during the zInter. optional, defaults to SUM
  *
  * @return int The number of values in the new sorted set.
  * @link http://redis.io/commands/zinterstore
  * @example
  * <pre>
  * $redis->delete('k1');
  * $redis->delete('k2');
  * $redis->delete('k3');
  * $redis->delete('ko1');
  * $redis->delete('ko2');
  * $redis->delete('ko3');
  * $redis->delete('ko4');
  * $redis->zAdd('k1', 0, 'val0');
  * $redis->zAdd('k1', 1, 'val1');
  * $redis->zAdd('k1', 3, 'val3');
  * $redis->zAdd('k2', 2, 'val1');
  * $redis->zAdd('k2', 3, 'val3');
  * $redis->zInter('ko1', array('k1', 'k2')); // 2, 'ko1' => array('val1', 'val3')
  * $redis->zInter('ko2', array('k1', 'k2'), array(1, 1)); // 2, 'ko2' => array('val1', 'val3')
  * // Weighted zInter
  * $redis->zInter('ko3', array('k1', 'k2'), array(1, 5), 'min'); // 2, 'ko3' => array('val1', 'val3')
  * $redis->zInter('ko4', array('k1', 'k2'), array(1, 5), 'max'); // 2, 'ko4' => array('val3', 'val1')
  * </pre>
  */
 public function zInter($output, array $zSetKeys, array $weights = array(), $aggregateFunction = 'SUM')
 {
     $this->appendToLog('ZINTER ' . implode(' ', $zSetKeys) . ' ' . implode(' ', $weights) . ' ' . $aggregateFunction);
     return $this->client->zInter($output, $zSetKeys, $weights, $aggregateFunction);
 }