原文
http://redis.io/commands/zrevrangebylex
简介
Return a range of members in a sorted set, by lexicographical range, ordered from higher to lower strings.
根据词典范围,返回有序集合中一定范围内的元素,按照字符串由高到低。
语法
ZREVRANGEBYLEX key max min [LIMIT offset count]
版本
Available since 2.8.9.
自2.8.9版本可用。
时间复杂度
Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements being returned. If M is constant (e.g. always asking for the first 10 elements with LIMIT), you can consider it O(log(N)).
O(log(N)+M):N是有序集合中元素的数量,M是返回的元素的数量。如果M是常量,你可以认为时间复杂度为O(log(N))。
描述
When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns all the elements in the sorted set at key with a value between max and min.
当有序集合中插入的所有元素的分数都相同时,为了强制词典排序,这个命令返回值在max和min之间的所有元素。
Apart from the reversed ordering, ZREVRANGEBYLEX is similar to ZRANGEBYLEX.
除了颠倒顺序,ZREVRANGEBYLEX与ZRANGEBYLEX是相似的。
返回值
Array reply: list of elements in the specified score range.
Array:指定范围的元素列表。
例子
redis> ZADD myzset 0 a 0 b 0 c 0 d 0 e 0 f 0 g
(integer) 7
redis> ZREVRANGEBYLEX myzset [c -
1) "c"
2) "b"
3) "a"
redis> ZREVRANGEBYLEX myzset (c -
1) "b"
2) "a"
redis> ZREVRANGEBYLEX myzset (g [aaa
1) "f"
2) "e"
3) "d"
4) "c"
5) "b"
redis>
相关推荐
6. 提供了更丰富的命令,例如`ZREVRANGEBYLEX`和`ZLEXCOUNT`,用于按字典顺序操作有序集合。 7. 优化了内存管理,包括更好的内存碎片控制和LRU(最近最少使用)淘汰算法。 要使用这个源文件,开发者需要先解压缩,...
3. 有序集合(Sorted Set)的改进:添加了`ZREVRANGEBYLEX`和`ZLEXCOUNT`命令,使得在有序集合中根据字典顺序进行查询成为可能。 4. Pub/Sub(发布/订阅)模式增强:允许消息过滤,提高消息传递的灵活性。 最后,...
2. 新增命令与功能:新版本可能引入了更多的数据操作命令,比如`BITFIELD`用于操作二进制位,或者`ZREVRANGEBYLEX`用于按照字典顺序反向获取有序集合元素。 3. 安全性增强:Redis 7.2.3可能提供了更强大的安全措施...
其中,有序集合新增了`ZREVRANGEBYLEX`等命令,可以根据字典顺序范围查询元素,为复杂查询提供了更多可能。 Redis 3.2.8还引入了流(Stream)数据类型,这是一种新的持久化数据结构,适合实现日志记录、时间序列...
6. ** ZSET(有序集合)的改进**:增加了ZRANGEBYLEX和ZREVRANGEBYLEX命令,按字典顺序范围查询。 综上所述,Redis作为一个强大的键值存储系统,因其高效、灵活和丰富的功能,在IT领域得到了广泛应用。了解和掌握...