在线工具
网站地图    收藏    合作   
<

快捷菜单 返回顶部

php操作redis

返回上层

zSet数据类型函数 - zInter - 命令/方法/函数

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 optionnel 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 AGGREGATEoption which specify how the results of the union are aggregated.

计算numkeys个由keys指定的有序集合的交集,并且将结果存储在destination中。在该命令中,在你传递输入keys之前,必须提供输入keys的个数和其它可选的参数。

在默认情况下,一个元素的结果score是具有该元素的所有有序集合的score的和。关于WEIGHTS和AGGREGATE选项,可以参看ZUNIONSTORE命令。如果目标已经存在,那么它将会被重写。


Parameters

keyOutput

arrayZSetKeys

arrayWeights

aggregateFunction Either "SUM", "MIN", or "MAX": defines the behaviour to use on duplicate entries during the zInter.


Return value

LONG The number of values in the new sorted set.


Example

$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') */


来源:https://www.daixiaorui.com/

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com