ZRANGEBYSCORE key min max [LIMIT offset count] (Redis >= 1.1)
ZRANGEBYSCORE key min max [LIMIT offset count] [WITHSCORES] (Redis >= 1.3.4)
Return 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 the number of elements returned by the command, so if M is constant (for instance you always ask for the first ten elements with LIMIT) you can consider it O(log(N))
RETURN VALUE: Multi bulk reply, specifically a list of elements in the specified score range.
Syntax:
ZRANGEBYSCORE key min max
Example 1: When the key is present.
redis:6379> ZADD mykey 1 A 2 B 3 C 4 D 5 E(integer) 5redis:6379> ZRANGEBYSCORE mykey 1 41) "A"2) "B"3) "C"4) "D"
Output
1) "A"
2) "B"
3) "C"
4) "D"
Example 2: When the key is not present.
redis:6379> ZRANGEBYSCORE redisKey 1 5(empty array)
Output
empty array
No comments:
Post a Comment