Redis – Sorted Set Zremrangebyscore Command

  • Post author:
  • Post category:Redis
  • Post comments:0 Comments

Redis ZREMRANGEBYSCORE command removes all the elements in the sorted set stored at the key with a score between min and max (inclusive).

Return Value

Integer reply, the number of elements removed.

Syntax

Following is the basic syntax of Redis ZREMRANGEBYSCORE command.

redis 127.0.0.1:6379> ZREMRANGEBYSCORE key min max

Example

redis 127.0.0.1:6379> ZADD myzset 1 b 2 c 3 d 4 e 
(integer) 4 
redis 127.0.0.1:6379> ZREMRANGEBYSCORE myzset -inf (2 
(integer) 1 
redis 127.0.0.1:6379> ZRANGE myzset 0 -1 WITHSCORES 
1) "b" 
2) "2" 
3) "c" 
4) "3" 
5) "d" 
6) "4" 
7) "e" 
8) "5"

Leave a Reply