🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## zInter ##### *Description* 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 `<span class="calibre12">weights</span>` to apply to the sorted sets in input. In this case, the `<span class="calibre12">weights</span>` will be multiplied by the score of each element in the sorted set before applying the aggregation. The forth argument defines the `<span class="calibre12">AGGREGATE</span>`option 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* ``` <pre class="calibre16">$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') */ ```