ZREMRANGEBYSCORE
Introduction
In Dragonfly, as well as in Redis and Valkey, the ZREMRANGEBYSCORE command is used to remove all members from a sorted set that have a score within a given range.
This command is often used in scenarios where you need to efficiently prune entries in a sorted set based on their scores, such as removing expired sessions or data points from a leaderboard.
Syntax
ZREMRANGEBYSCORE key min max
- 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.
- ACL categories: @write, @sortedset, @slow
Parameter Explanations
key: The name of the sorted set.minandmax:- The minimum and maximum score values to filter the members to be removed.
- By default, they are inclusive. To make them exclusive, use the
(character before the score. - The
+infand-infspecial values can be used to specify positive and negative infinity scores, respectively.
Return Values
- The command returns an integer indicating the number of members removed from the sorted set.