ZREMRANGEBYSCORE key min max
Remove all the elements in the sorted set at a key with a score between min and max (including elements with a score equal to min or max).
TIME COMPLEXITY: O(log(N))+O(M) with N being the number of elements in the sorted set and M being the number of elements removed by the operation.
RETURN VALUE: Integer reply, specifically the number of elements removed.
Syntax:
ZREMRANGEBYSCORE key min max
Example 1: When the key is present and min and max in the range.
redis:6379> ZADD mykey 1 A 2 B 3 C 4 D 5 E(integer) 5redis:6379> ZREMRANGEBYSCORE mykey 1 3(integer) 2
Output
2
Example 2: When the key is not present or min and max is out of range.
redis:6379> ZADD mykey 1 A 2 B 3 C 4 D 5 E(integer) 5redis:6379> ZREMRANGEBYSCORE myredisKey 1 4(integer) 0redis:6379> ZREMRANGEBYSCORE mykey 10 20(integer) 0
Output
0
No comments:
Post a Comment