Easy Tutorial
❮ Keys Pexpire Keys Rename ❯

Redis Zremrangebyscore Command

Redis Sorted Set

The Redis Zremrangebyscore command is used to remove all members in a sorted set within the specified score range.

Syntax

The basic syntax for the redis Zremrangebyscore command is as follows:

redis 127.0.0.1:6379> ZREMRANGEBYSCORE key min max

Available Versions

= 1.2.0

Return Value

The number of removed members.

Example

redis 127.0.0.1:6379> ZRANGE salary 0 -1 WITHSCORES          # Display all members and their score values
1) "tom"
2) "2000"
3) "peter"
4) "3500"
5) "jack"
6) "5000"

redis 127.0.0.1:6379> ZREMRANGEBYSCORE salary 1500 3500      # Remove all employees with salaries between 1500 and 3500
(integer) 2

redis> ZRANGE salary 0 -1 WITHSCORES          # Remaining members in the sorted set
1) "jack"
2) "5000"

Redis Sorted Set

❮ Keys Pexpire Keys Rename ❯