Redis Sorted Sets: ZREMRANGEBYLEX
Redis ZREMRANGEBYLEX Command
Redis ZREMRANGEBYLEX command is used to remove all elements in the sorted set stored at key between the lexicographical range specified by minimum and maximum values, when all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering.
Here are some common uses and scenarios for the "ZREMRANGEBYLEX" command:
- Lexicographical Range Removal: Remove members from a sorted set within a specified lexicographical range.
- Data Management: Clean up and manage data by removing members based on their keys.
- String Handling: Manage strings by removing elements within specific lexicographical bounds.
- Indexing: Efficiently remove elements from sorted sets based on lexicographical criteria.
- Data Integrity: Ensure data integrity by removing elements that fall within undesired lexicographical ranges.
Syntax:
ZREMRANGEBYLEX key min max
Available since
2.8.9.
Return Value
Integer reply, the number of elements removed.
Return Value Type
Integer
Example: Redis ZREMRANGEBYLEX
127.0.0.1:6379> ZADD mycityset 0 Delhi 0 Mumbai 0 Hyderabad 0 Kolkata 0 Chennai (integer) 5 127.0.0.1:6379> ZRANGEBYLEX mycityset - + 1) "Chennai" 2) "Delhi" 3) "Hyderabad" 4) "Kolkata" 5) "Mumbai" 127.0.0.1:6379> ZREMRANGEBYLEX mycityset "(Hyderabad" "(Mumbai" (integer) 1 127.0.0.1:6379> ZRANGEBYLEX mycityset - + 1) "Chennai" 2) "Delhi" 3) "Hyderabad" 4) "Mumbai" 127.0.0.1:6379> ZREMRANGEBYLEX mycityset "[Hyderabad" "(Mumbai" (integer) 1 127.0.0.1:6379> ZRANGEBYLEX mycityset - + 1) "Chennai" 2) "Delhi" 3) "Mumbai" 127.0.0.1:6379> ZREMRANGEBYLEX mycityset "[Hyderabad" "[Mumbai" (integer) 1 127.0.0.1:6379> ZRANGEBYLEX mycityset - + 1) "Chennai" 2) "Delhi"
Previous:
ZREM
Next:
ZREMRANGEBYRANK
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-zremrangebylex-key-min-max.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics