Redis Sorted Sets: ZREVRANGEBYLEX
Redis ZREVRANGEBYLEX Command
Redis ZREVRANGEBYLEX command is used to return the specified range of elements in the sorted set stored at key between maxium and minimum value, when all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering. The elements are considered to be ordered from the the highest to lowest score.
- min, max are the range of the member. To view all the -, + use.
- min, if you give the max value must be used '[' or '(' in the front.
- '[' Is used to contain a value, and '(' is used to block out.
Both start and stop are zero-based indexes,
- 0 is the first element,
- 1 is the next element and so on.
They can also be negative numbers indicating offsets from the end of the sorted set,
- -1 being the last element of the sorted set
- -2 the penultimate element and so on.
Here are some common uses and scenarios for the "ZREVRANGEBYLEX" command:
- Reverse Lexicographical Queries: Fetch elements within a specified lexicographical range in descending order.
- Alphabetical Sorting: Retrieve elements sorted alphabetically in reverse order based on their keys.
- Data Segmentation: Segment data based on reverse lexicographical ranges for further processing.
- String Management: Manage and retrieve strings within specific reverse lexicographical bounds.
- Indexing: Create indices for efficient retrieval of elements based on reverse lexicographical criteria.
Syntax:
ZREVRANGEBYLEX key max min [LIMIT offset count]
Available since
2.8.9.
Return Value
Array reply, list of elements in the specified score range.
Return Value Type
Array
Example: Redis ZREVRANGEBYLEX
127.0.0.1:6379> ZADD mycity 0 Delhi 0 London 0 Paris 0 Tokyo 0 NewYork 0 Seoul (integer) 6 127.0.0.1:6379> ZREVRANGEBYLEX mycity + - 1) "Tokyo" 2) "Seoul" 3) "Paris" 4) "NewYork" 5) "London" 6) "Delhi" 127.0.0.1:6379> ZREVRANGEBYLEX mycity + "[Paris" 1) "Tokyo" 2) "Seoul" 3) "Paris" 127.0.0.1:6379> ZREVRANGEBYLEX mycity "(NewYork" "[London" 1) "London" 127.0.0.1:6379> ZREVRANGEBYLEX mycity "(Seoul" "[Delhi" 1) "Paris" 2) "NewYork" 3) "London" 4) "Delhi"
Example: Redis ZREVRANGEBYLEX: Use limit offset count
127.0.0.1:6379> ZADD mycity 0 Delhi 0 London 0 Paris 0 Tokyo 0 NewYork 0 Seoul (integer) 6 127.0.0.1:6379> ZREVRANGEBYLEX mycity + - 1) "Tokyo" 2) "Seoul" 3) "Paris" 4) "NewYork" 5) "London" 6) "Delhi" 127.0.0.1:6379> ZREVRANGEBYLEX mycity + - LIMIT 0 2 1) "Tokyo" 2) "Seoul" 127.0.0.1:6379> ZREVRANGEBYLEX mycity + - LIMIT 2 3 1) "Paris" 2) "NewYork" 3) "London"
Previous:
ZREVRANGE
Next:
ZREVRANGEBYSCORE
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/redis/redis-zrevrangebylex.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics