ZCOUNT

Syntax
ZCOUNT key min max
Available since:
2.0.0
Time complexity:
O(log(N)) with N being the number of elements in the sorted set.
ACL categories:
@read, @sortedset, @fast,

返回在key中分数介于minmax之间的有序集合中的元素数量。

minmax 参数具有与 ZRANGEBYSCORE 中描述的相同语义。

注意:该命令的复杂度仅为O(log(N)),因为它使用元素排名(参见ZRANK)来获取范围的概念。因此,不需要做与范围大小成正比的工作。

示例

ZADD myzset 1 "one" ZADD myzset 2 "two" ZADD myzset 3 "three" ZCOUNT myzset -inf +inf ZCOUNT myzset (1 3

RESP2/RESP3 回复

Integer reply: the number of members in the specified score range.
RATE THIS PAGE
Back to top ↑