The elements having the same score are returned sorted lexicographically as ASCII strings (this follows from a property of Redis sorted sets and does not involve further computation).
Using the optional {@link #zrangeByScore(String,double,double,int,int) LIMIT} it'spossible to get only a range of the matching elements in an SQL-alike way. Note that if offset is large the commands needs to traverse the list for offset elements and this adds up to the O(M) figure.
The {@link #zcount(String,double,double) ZCOUNT} command is similar to{@link #zrangeByScore(String,double,double) ZRANGEBYSCORE} but insteadof returning the actual elements in the specified interval, it just returns the number of matching elements.
Exclusive intervals and infinity
min and max can be -inf and +inf, so that you are not required to know what's the greatest or smallest element in order to take, for instance, elements "up to a given value".
Also while the interval is for default closed (inclusive) it's possible to specify open intervals prefixing the score with a "(" character, so for instance:
{@code ZRANGEBYSCORE zset (1.3 5}
Will return all the values with score > 1.3 and <= 5, while for instance:
{@code ZRANGEBYSCORE zset (5 (10}
Will return all the values with score > 5 and < 10 (5 and 10 excluded).
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)) @see #zrangeByScore(String,double,double) @see #zrangeByScore(String,double,double,int,int) @see #zrangeByScoreWithScores(String,double,double) @see #zrangeByScoreWithScores(String,String,String) @see #zrangeByScoreWithScores(String,double,double,int,int) @see #zcount(String,double,double) @param key @param min a double or Double.MIN_VALUE for "-inf" @param max a double or Double.MAX_VALUE for "+inf" @return Multi bulk reply specifically a list of elements in the specifiedscore range.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|