w3resource

Redis Sorted Sets: ZREMRANGEBYSCORE

ZREMRANGEBYSCORE key min max

Redis ZREMRANGEBYSCORE command is used to remove all elements in the sorted set stored at the key with a score between the minimum and maximum value.

min, max in the range of score. To delete all use -inf, + inf.

Syntax

ZREMRANGEBYSCORE key min max

Available since

2.2.0.

Return Value

Integer reply, the number of elements removed.

Return Value Type

Integer

Example: Redis ZREMRANGEBYSCORE

127.0.0.1:6379> ZADD mycityset 80 Delhi 60 Mumbai 70 Hyderabad 50 Kolkata 65 Chennai
(integer) 5
127.0.0.1:6379> ZRANGEBYSCORE mycityset -inf +inf  WITHSCORES
 1) "Kolkata"
 2) "50"
 3) "Mumbai"
 4) "60"
 5) "Chennai"
 6) "65"
 7) "Hyderabad"
 8) "70"
 9) "Delhi"
10) "80"
127.0.0.1:6379> ZREMRANGEBYSCORE mycityset -inf (70
(integer) 3
127.0.0.1:6379> ZRANGEBYSCORE mycityset -inf +inf  WITHSCORES
1) "Hyderabad"
2) "70"
3) "Delhi"
4) "80"
127.0.0.1:6379> ZREMRANGEBYSCORE mycityset -inf 70
(integer) 1
127.0.0.1:6379> ZRANGEBYSCORE mycityset -inf +inf  WITHSCORES
1) "Delhi"
2) "80"

Previous: ZREMRANGEBYRANK
Next: ZREVRANGE



Follow us on Facebook and Twitter for latest update.