Redis command - ordered collection - zremrangebyscore

 

original

http://redis.io/commands/zremrangebyscore

 

Introduction

Remove all members in a sorted set within the given scores.

 

Removes all members within the specified score range from the sorted set.

 

grammar

ZREMRANGEBYSCORE key min max

 

Version

Available since 1.2.0.

 

Available since version 1.2.0.

 

time complexity

Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements removed by the operation.

 

O(log(N)+M): N is the number of elements in the sorted set and M is the number of elements to remove.

 

describe

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

 

Removes all elements with scores between min and max inclusive from the sorted set.

 

Since version 2.1.6, min and max can be exclusive, following the syntax of ZRANGEBYSCORE.

 

Since Redis 2.1.6, min and max can be excluded, same as ZRANGEBYSCORE syntax.

 

return value

Integer reply: the number of elements removed.

 

Integer: The number of elements removed.

 

example

redis>  ZADD myzset 1 "one"
(integer) 1
redis>  ZADD myzset 2 "two"
(integer) 1
redis>  ZADD myzset 3 "three"
(integer) 1
redis>  ZREMRANGEBYSCORE myzset -inf (2
(integer) 1
redis>  ZRANGE myzset 0 -1 WITHSCORES
1) "two"
2) "2"
3) "three"
4) "3"
redis>

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326950523&siteId=291194637