ZINTERCARD

Syntax
ZINTERCARD numkeys key [key ...] [LIMIT limit]
Available since:
7.0.0
Time complexity:
O(N*K) worst case with N being the smallest input sorted set, K being the number of input sorted sets.
ACL categories:
@read, @sortedset, @slow,

此命令类似于ZINTER,但它不返回结果集,而是仅返回结果的基数。

不存在的键被视为空集。 如果其中一个键是空集,结果集也是空的(因为与空集的交集总是产生空集)。

默认情况下,该命令计算所有给定集合的交集的基数。 当提供可选的LIMIT参数(默认为0,表示无限制)时,如果在计算过程中交集的基数达到限制,算法将退出并将限制作为基数。 这种实现确保了在限制低于实际交集基数的查询中显著加速。

示例

ZADD zset1 1 "one" ZADD zset1 2 "two" ZADD zset2 1 "one" ZADD zset2 2 "two" ZADD zset2 3 "three" ZINTER 2 zset1 zset2 ZINTERCARD 2 zset1 zset2 ZINTERCARD 2 zset1 zset2 LIMIT 1

RESP2/RESP3 回复

Integer reply: the number of members in the resulting intersection.
RATE THIS PAGE
Back to top ↑