原文
http://redis.io/commands/zlexcount
简介
Count the number of members in a sorted set between a given lexicographical range.
计算有序集合中在指定词典范围内的成员的数量。
语法
ZLEXCOUNT key min max
版本
Available since 2.8.9.
自2.8.9版本可用。
时间复杂度
Time complexity: O(log(N)) with N being the number of elements in the sorted set.
O(log(N)):N是有序集合中元素的数量。
描述
When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns the number of elements in the sorted set at key with a value between min and max.
当有序集合中插入的所有元素的分数相同时,为了强制进行词典排序,这个命令返回值在min到max之间的元素的数量。
The min and max arguments have the same meaning as described for ZRANGEBYLEX.
参数min和max与ZRANGEBYLEX命令有相同的含义。
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.
Integer:指定值范围内的元素的数量。
例子
redis> ZADD myzset 0 a 0 b 0 c 0 d 0 e
(integer) 5
redis> ZADD myzset 0 f 0 g
(integer) 2
redis> ZLEXCOUNT myzset - +
(integer) 7
redis> ZLEXCOUNT myzset [b [f
(integer) 5
redis>
相关推荐
6. 提供了更丰富的命令,例如`ZREVRANGEBYLEX`和`ZLEXCOUNT`,用于按字典顺序操作有序集合。 7. 优化了内存管理,包括更好的内存碎片控制和LRU(最近最少使用)淘汰算法。 要使用这个源文件,开发者需要先解压缩,...
3. 有序集合(Sorted Set)的改进:添加了`ZREVRANGEBYLEX`和`ZLEXCOUNT`命令,使得在有序集合中根据字典顺序进行查询成为可能。 4. Pub/Sub(发布/订阅)模式增强:允许消息过滤,提高消息传递的灵活性。 最后,...
- **ZLEXCOUNT key min max**:返回有序集合`key`中所有成员的元素处于给定区间内的数量。 - **ZREMRANGEBYLEX key min max**:移除有序集合`key`中所有成员的元素处于给定区间内的结果。 - **ZSCAN key cursor ...
6. **新命令和改进**:包括`ZREMRANGEBYLEX`(根据字典顺序删除有序集合的元素)、`ZLEXCOUNT`(计算有序集合中字典范围内的元素数量)等,增强了对有序集合的操作。 7. **客户端断线重连**:Redis 3.2改进了客户端...
Redis 有序集合(Sorted Set)是一种特殊的集合数据结构,它结合了集合的无重复成员特性与分数的概念,可以根据成员的分数进行排序。有序集合中的每个成员都有一个与之关联的double类型的分数,这个分数用于决定成员...