Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Redis Zremrangebyscore command

Redis Zremrangebyscore command

Redis Sorted Set

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

Syntax

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



redis 127.0.0.1:6379> ZREMRANGEBYSCORE key min max

Available Version

= 1.2.0

Return Value

The number of members removed.

Example



redis 127.0.0.1:6379> ZRANGE salary 0 -1 WITHSCORES          # 显示有序集内所有成员及其 score 值

1) "tom"

2) "2000"

3) "peter"

4) "3500"

5) "jack"

6) "5000"



redis 127.0.0.1:6379> ZREMRANGEBYSCORE salary 1500 3500      # 移除所有薪水在 1500 到 3500 内的员工

(integer) 2



redis> ZRANGE salary 0 -1 WITHSCORES          # 剩下的有序集成员

1) "jack"

2) "5000"

Redis Sorted Set