Redis Sorted Sets: ZLEXCOUNT
Redis ZLEXCOUNT Command
Redis ZLEXCOUNT command is used to return the number of elements in the sorted set at the key with a value between minimum and maximum when all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering.
- 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.
Here are some common uses and scenarios for the "ZLEXCOUNT" command:
- Lexicographical Queries: Count members within a specified lexicographical range to retrieve relevant data.
- Alphabetical Sorting: Perform alphabetical sorting by counting elements based on lexicographical order.
- Data Segmentation: Segment data based on lexicographical ranges to facilitate further processing or analysis.
- String Management: Manage strings by counting elements within certain lexicographical bounds.
Syntax:
ZLEXCOUNT KEY MIN MAX
Available since
2.8.9.
Return Value
Integer replies the number of elements in the specified score range.
Return Value Type
Integer
Example: Redis ZLEXCOUNT
127.0.0.1:6379> ZADD mycityset 1 Delhi 1 Mumbai 1 London 1 Paris 1 Tokyo (integer) 5 127.0.0.1:6379> ZRANGEBYLEX mycityset - + 1) "Delhi" 2) "London" 3) "Mumbai" 4) "Paris" 5) "Tokyo" 127.0.0.1:6379> ZLEXCOUNT mycityset "[London" + (integer) 4 127.0.0.1:6379> ZLEXCOUNT mycityset "(London" + (integer) 3 127.0.0.1:6379> ZLEXCOUNT mycityset "(London" "(Paris" (integer) 1 127.0.0.1:6379> ZLEXCOUNT mycityset "[London" "(Paris" (integer) 2
Previous:
ZINTERSTORE
Next:
ZRANGE
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://w3resource.com/redis/redis-zlexcount-key-min-max.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics