directory search
Cluster cluster addslots(集群 槽位) cluster count failure reports(集群计数失败报告) cluster countkeysinslot cluster delslots cluster failover cluster forget cluster getkeysinslot cluster info cluster keyslot(集群键槽) cluster meet cluster nodes(集群节点) cluster replicate(集群复制) cluster reset(集群重置) cluster saveconfig cluster set config epoch cluster setslot cluster slaves cluster slots readonly readwrite Connection auth echo ping quit select swapdb Geo geoadd geodist geohash geopos georadius georadiusbymember Hashes hdel hexists hget hgetall hincrby hincrbyfloat hkeys hlen hmget hmset hscan hset hsetnx hstrlen hvals HyperLogLog pfadd pfcount pfmerge Keys del dump exists expire expireat keys migrate move object persist pexpire pexpireat pttl randomkey rename renamenx restore scan sort touch ttl type unlink wait Lists blpop brpop brpoplpush lindex linsert llen lpop lpush lpushx lrange lrem lset ltrim rpop rpoplpush rpush rpushx Pub/Sub psubscribe publish pubsub punsubscribe subscribe unsubscribe Scripting eval evalsha script debug script exists script flush script kill script load Server bgrewriteaof bgsave client getname client kill client list client pause client reply client setname command command count command getkeys command info config get config resetstat config rewrite config set dbsize debug object debug segfault flushall flushdb info lastsave monitor role save shutdown slaveof slowlog time Sets sadd scard sdiff sdiffstore sinter sinterstore sismember smembers smove spop srandmember srem sscan sunion sunionstore Sorted Sets zadd zcard zcount zincrby zinterstore zlexcount zrange zrangebylex zrangebyscore zrank zrem zremrangebylex zremrangebyrank zremrangebyscore zrevrange zrevrangebylex zrevrangebyscore zrevrank zscan zscore zunionstore Strings append bitcount bitfield bitop bitpos decr decrby get getbit getrange getset incr incrby incrbyfloat mget mset msetnx psetex set setbit setex setnx setrange strlen Transactions discard exec multi unwatch watch
characters

ZINTERSTORE destination numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX]

自2.0.0起可用。

时间复杂度: O(N * K)+ O(M * log(M))最坏的情况,N 是最小的输入排序集合,K 是输入排序集合的数量,M 是结果排序集合中的元素数量。

计算numkeys由指定键给出的已排序集合的交集,并将结果存储在中destinationnumkeys在传递输入键和其他(可选)参数之前,必须提供输入键()的数量。

默认情况下,元素的结果得分是其存在的有序集合中的得分总和。因为交集需要一个元素成为每个给定的有序集合的成员,所以这导致结果集合中的每个元素的得分等于输入的有序集合的数量。

有关WEIGHTSAGGREGATE选项的说明,请参阅 ZUNIONSTORE 。

如果destination已经存在,它将被覆盖。

返回值

整数回复:在destination得到的排序集中的元素数。

例子

redis>  ZADD zset1 1 "one" (integer) 1 

redis>  ZADD zset1 2 "two" (integer) 1 

redis>  ZADD zset2 1 "one" (integer) 1 

redis>  ZADD zset2 2 "two" (integer) 1 

redis>  ZADD zset2 3 "three" (integer) 1 

redis>  ZINTERSTORE out 2 zset1 zset2 WEIGHTS 2 3 (integer) 2 

redis>  ZRANGE out 0 -1 WITHSCORES 1) "one" 2) "5" 3) "two" 4) "10"

Previous article: Next article: