Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

Redis Sorted Sets: ZREMRANGEBYLEX

ZREMRANGEBYLEX key min max

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.

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