Redis命令-有序集合-zcount

 

原文

http://redis.io/commands/zcount

 

简介

Count the members in a sorted set with scores within the given values.

 

计算有序集合中分数在指定值范围内的元素的数量。

 

语法

ZCOUNT key min max

 

版本

Available since 2.0.0.

 

自2.0.0版本可用。

 

时间复杂度

Time complexity: O(log(N)) with N being the number of elements in the sorted set.

 

O(log(N)):N是有序集合中元素的数量。

 

描述

Returns the number of elements in the sorted set at key with a score between min and max.

 

返回有序集合中分数在min和max之间的元素的数量。

 

The min and max arguments have the same semantic as described for ZRANGEBYSCORE.

 

参数min和max与ZRANGEBYSCORE命令具有相同的语义。

 

Note: the command has a complexity of just O(log(N)) because it uses elements ranks (see ZRANK) to get an idea of the range. Because of this there is no need to do a work proportional to the size of the range.

 

返回值

Integer reply: the number of elements in the specified score range.

 

整数:指定分数范围内元素的数量。

 

例子

redis>  ZADD myzset 1 "one"
(integer) 1
redis>  ZADD myzset 2 "two"
(integer) 1
redis>  ZADD myzset 3 "three"
(integer) 1
redis>  ZCOUNT myzset -inf +inf
(integer) 3
redis>  ZCOUNT myzset (1 3
(integer) 2
redis>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值