Implementation of ZREVRANGEBYSCORE command
This commit is contained in:
@@ -477,6 +477,10 @@ public class BinaryClient extends Connection {
|
||||
final double max) {
|
||||
sendCommand(ZRANGEBYSCORE, key, toByteArray(min), toByteArray(max));
|
||||
}
|
||||
public void zrevrangeByScore(final byte[] key, final double max,
|
||||
final double min) {
|
||||
sendCommand(ZREVRANGEBYSCORE, key, toByteArray(max), toByteArray(min));
|
||||
}
|
||||
|
||||
public void zrangeByScore(final byte[] key, final byte[] min,
|
||||
final byte[] max) {
|
||||
@@ -488,12 +492,22 @@ public class BinaryClient extends Connection {
|
||||
sendCommand(ZRANGEBYSCORE, key, toByteArray(min), toByteArray(max),
|
||||
LIMIT.raw, toByteArray(offset), toByteArray(count));
|
||||
}
|
||||
public void zrevrangeByScore(final byte[] key, final double max,
|
||||
final double min, final int offset, int count) {
|
||||
sendCommand(ZREVRANGEBYSCORE, key, toByteArray(max), toByteArray(min),
|
||||
LIMIT.raw, toByteArray(offset), toByteArray(count));
|
||||
}
|
||||
|
||||
public void zrangeByScoreWithScores(final byte[] key, final double min,
|
||||
final double max) {
|
||||
sendCommand(ZRANGEBYSCORE, key, toByteArray(min), toByteArray(max),
|
||||
WITHSCORES.raw);
|
||||
}
|
||||
public void zrevrangeByScoreWithScores(final byte[] key, final double max,
|
||||
final double min) {
|
||||
sendCommand(ZREVRANGEBYSCORE, key, toByteArray(max), toByteArray(min),
|
||||
WITHSCORES.raw);
|
||||
}
|
||||
|
||||
public void zrangeByScoreWithScores(final byte[] key, final double min,
|
||||
final double max, final int offset, final int count) {
|
||||
@@ -501,6 +515,12 @@ public class BinaryClient extends Connection {
|
||||
LIMIT.raw, toByteArray(offset), toByteArray(count),
|
||||
WITHSCORES.raw);
|
||||
}
|
||||
public void zrevrangeByScoreWithScores(final byte[] key, final double max,
|
||||
final double min, final int offset, final int count) {
|
||||
sendCommand(ZREVRANGEBYSCORE, key, toByteArray(max), toByteArray(min),
|
||||
LIMIT.raw, toByteArray(offset), toByteArray(count),
|
||||
WITHSCORES.raw);
|
||||
}
|
||||
|
||||
public void zremrangeByRank(final byte[] key, final int start, final int end) {
|
||||
sendCommand(ZREMRANGEBYRANK, key, toByteArray(start), toByteArray(end));
|
||||
@@ -652,4 +672,4 @@ public class BinaryClient extends Connection {
|
||||
public void getrange(byte[] key, long startOffset, long endOffset) {
|
||||
sendCommand(GETRANGE, key, toByteArray(startOffset), toByteArray(endOffset));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -412,6 +412,10 @@ public class Client extends BinaryClient implements Commands {
|
||||
final double max) {
|
||||
zrangeByScore(SafeEncoder.encode(key), min, max);
|
||||
}
|
||||
public void zrevrangeByScore(final String key, final double max,
|
||||
final double min) {
|
||||
zrevrangeByScore(SafeEncoder.encode(key), max, min);
|
||||
}
|
||||
|
||||
public void zrangeByScore(final String key, final String min,
|
||||
final String max) {
|
||||
@@ -423,17 +427,30 @@ public class Client extends BinaryClient implements Commands {
|
||||
final double max, final int offset, int count) {
|
||||
zrangeByScore(SafeEncoder.encode(key), min, max, offset, count);
|
||||
}
|
||||
public void zrevrangeByScore(final String key, final double max,
|
||||
final double min, final int offset, int count) {
|
||||
zrevrangeByScore(SafeEncoder.encode(key), max, min, offset, count);
|
||||
}
|
||||
|
||||
public void zrangeByScoreWithScores(final String key, final double min,
|
||||
final double max) {
|
||||
zrangeByScoreWithScores(SafeEncoder.encode(key), min, max);
|
||||
}
|
||||
public void zrevrangeByScoreWithScores(final String key, final double max,
|
||||
final double min) {
|
||||
zrevrangeByScoreWithScores(SafeEncoder.encode(key), max, min);
|
||||
}
|
||||
|
||||
public void zrangeByScoreWithScores(final String key, final double min,
|
||||
final double max, final int offset, final int count) {
|
||||
zrangeByScoreWithScores(SafeEncoder.encode(key), min, max, offset,
|
||||
count);
|
||||
}
|
||||
public void zrevrangeByScoreWithScores(final String key, final double max,
|
||||
final double min, final int offset, final int count) {
|
||||
zrevrangeByScoreWithScores(SafeEncoder.encode(key), max, min, offset,
|
||||
count);
|
||||
}
|
||||
|
||||
public void zremrangeByRank(final String key, final int start, final int end) {
|
||||
zremrangeByRank(SafeEncoder.encode(key), start, end);
|
||||
@@ -560,4 +577,4 @@ public class Client extends BinaryClient implements Commands {
|
||||
}
|
||||
subscribe(cs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2085,6 +2085,12 @@ public class Jedis extends BinaryJedis implements JedisCommands {
|
||||
client.zrangeByScore(key, min, max);
|
||||
return new LinkedHashSet<String>(client.getMultiBulkReply());
|
||||
}
|
||||
public Set<String> zrevrangeByScore(final String key, final double max,
|
||||
final double min) {
|
||||
runChecks();
|
||||
client.zrevrangeByScore(key, max, min);
|
||||
return new LinkedHashSet<String>(client.getMultiBulkReply());
|
||||
}
|
||||
|
||||
public Set<String> zrangeByScore(final String key, final String min,
|
||||
final String max) {
|
||||
@@ -2155,6 +2161,12 @@ public class Jedis extends BinaryJedis implements JedisCommands {
|
||||
client.zrangeByScore(key, min, max, offset, count);
|
||||
return new LinkedHashSet<String>(client.getMultiBulkReply());
|
||||
}
|
||||
public Set<String> zrevrangeByScore(final String key, final double max,
|
||||
final double min, final int offset, final int count) {
|
||||
runChecks();
|
||||
client.zrevrangeByScore(key, max, min, offset, count);
|
||||
return new LinkedHashSet<String>(client.getMultiBulkReply());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the all the elements in the sorted set at key with a score between
|
||||
@@ -2219,6 +2231,13 @@ public class Jedis extends BinaryJedis implements JedisCommands {
|
||||
Set<Tuple> set = getTupledSet();
|
||||
return set;
|
||||
}
|
||||
public Set<Tuple> zrevrangeByScoreWithScores(final String key,
|
||||
final double max, final double min) {
|
||||
runChecks();
|
||||
client.zrevrangeByScoreWithScores(key, max, min);
|
||||
Set<Tuple> set = getTupledSet();
|
||||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the all the elements in the sorted set at key with a score between
|
||||
@@ -2284,6 +2303,14 @@ public class Jedis extends BinaryJedis implements JedisCommands {
|
||||
Set<Tuple> set = getTupledSet();
|
||||
return set;
|
||||
}
|
||||
public Set<Tuple> zrevrangeByScoreWithScores(final String key,
|
||||
final double max, final double min, final int offset,
|
||||
final int count) {
|
||||
runChecks();
|
||||
client.zrevrangeByScoreWithScores(key, max, min, offset, count);
|
||||
Set<Tuple> set = getTupledSet();
|
||||
return set;
|
||||
}
|
||||
|
||||
private Set<Tuple> getTupledSet() {
|
||||
runChecks();
|
||||
@@ -2607,4 +2634,4 @@ public class Jedis extends BinaryJedis implements JedisCommands {
|
||||
client.getrange(key, startOffset, endOffset);
|
||||
return client.getBulkReply();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,14 +136,20 @@ public interface JedisCommands {
|
||||
Long zcount(String key, double min, double max);
|
||||
|
||||
Set<String> zrangeByScore(String key, double min, double max);
|
||||
Set<String> zrevrangeByScore(String key, double max, double min);
|
||||
|
||||
Set<String> zrangeByScore(String key, double min, double max, int offset,
|
||||
int count);
|
||||
Set<String> zrevrangeByScore(String key, double max, double min, int offset,
|
||||
int count);
|
||||
|
||||
Set<Tuple> zrangeByScoreWithScores(String key, double min, double max);
|
||||
Set<Tuple> zrevrangeByScoreWithScores(String key, double max, double min);
|
||||
|
||||
Set<Tuple> zrangeByScoreWithScores(String key, double min, double max,
|
||||
int offset, int count);
|
||||
Set<Tuple> zrevrangeByScoreWithScores(String key, double max, double min,
|
||||
int offset, int count);
|
||||
|
||||
Long zremrangeByRank(String key, int start, int end);
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ public final class Protocol {
|
||||
}
|
||||
|
||||
public static enum Command {
|
||||
PING, SET, GET, QUIT, EXISTS, DEL, TYPE, FLUSHDB, KEYS, RANDOMKEY, RENAME, RENAMENX, RENAMEX, DBSIZE, EXPIRE, EXPIREAT, TTL, SELECT, MOVE, FLUSHALL, GETSET, MGET, SETNX, SETEX, MSET, MSETNX, DECRBY, DECR, INCRBY, INCR, APPEND, SUBSTR, HSET, HGET, HSETNX, HMSET, HMGET, HINCRBY, HEXISTS, HDEL, HLEN, HKEYS, HVALS, HGETALL, RPUSH, LPUSH, LLEN, LRANGE, LTRIM, LINDEX, LSET, LREM, LPOP, RPOP, RPOPLPUSH, SADD, SMEMBERS, SREM, SPOP, SMOVE, SCARD, SISMEMBER, SINTER, SINTERSTORE, SUNION, SUNIONSTORE, SDIFF, SDIFFSTORE, SRANDMEMBER, ZADD, ZRANGE, ZREM, ZINCRBY, ZRANK, ZREVRANK, ZREVRANGE, ZCARD, ZSCORE, MULTI, DISCARD, EXEC, WATCH, UNWATCH, SORT, BLPOP, BRPOP, AUTH, SUBSCRIBE, PUBLISH, UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, ZCOUNT, ZRANGEBYSCORE, ZREMRANGEBYRANK, ZREMRANGEBYSCORE, ZUNIONSTORE, ZINTERSTORE, SAVE, BGSAVE, BGREWRITEAOF, LASTSAVE, SHUTDOWN, INFO, MONITOR, SLAVEOF, CONFIG, STRLEN, SYNC, LPUSHX, PERSIST, RPUSHX, ECHO, LINSERT, DEBUG, BRPOPLPUSH, SETBIT, GETBIT, SETRANGE, GETRANGE;
|
||||
PING, SET, GET, QUIT, EXISTS, DEL, TYPE, FLUSHDB, KEYS, RANDOMKEY, RENAME, RENAMENX, RENAMEX, DBSIZE, EXPIRE, EXPIREAT, TTL, SELECT, MOVE, FLUSHALL, GETSET, MGET, SETNX, SETEX, MSET, MSETNX, DECRBY, DECR, INCRBY, INCR, APPEND, SUBSTR, HSET, HGET, HSETNX, HMSET, HMGET, HINCRBY, HEXISTS, HDEL, HLEN, HKEYS, HVALS, HGETALL, RPUSH, LPUSH, LLEN, LRANGE, LTRIM, LINDEX, LSET, LREM, LPOP, RPOP, RPOPLPUSH, SADD, SMEMBERS, SREM, SPOP, SMOVE, SCARD, SISMEMBER, SINTER, SINTERSTORE, SUNION, SUNIONSTORE, SDIFF, SDIFFSTORE, SRANDMEMBER, ZADD, ZRANGE, ZREM, ZINCRBY, ZRANK, ZREVRANK, ZREVRANGE, ZCARD, ZSCORE, MULTI, DISCARD, EXEC, WATCH, UNWATCH, SORT, BLPOP, BRPOP, AUTH, SUBSCRIBE, PUBLISH, UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, ZCOUNT, ZRANGEBYSCORE, ZREVRANGEBYSCORE, ZREMRANGEBYRANK, ZREMRANGEBYSCORE, ZUNIONSTORE, ZINTERSTORE, SAVE, BGSAVE, BGREWRITEAOF, LASTSAVE, SHUTDOWN, INFO, MONITOR, SLAVEOF, CONFIG, STRLEN, SYNC, LPUSHX, PERSIST, RPUSHX, ECHO, LINSERT, DEBUG, BRPOPLPUSH, SETBIT, GETBIT, SETRANGE, GETRANGE;
|
||||
|
||||
public final byte[] raw;
|
||||
|
||||
@@ -153,4 +153,4 @@ public final class Protocol {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,23 +353,41 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrangeByScore(key, min, max);
|
||||
}
|
||||
public Set<String> zrevrangeByScore(String key, double max, double min) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrangeByScore(key, max, min);
|
||||
}
|
||||
|
||||
public Set<String> zrangeByScore(String key, double min, double max,
|
||||
int offset, int count) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrangeByScore(key, min, max, offset, count);
|
||||
}
|
||||
public Set<String> zrevrangeByScore(String key, double max, double min,
|
||||
int offset, int count) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrangeByScore(key, max, min, offset, count);
|
||||
}
|
||||
|
||||
public Set<Tuple> zrangeByScoreWithScores(String key, double min, double max) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrangeByScoreWithScores(key, min, max);
|
||||
}
|
||||
public Set<Tuple> zrevrangeByScoreWithScores(String key, double max, double min) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrangeByScoreWithScores(key, max, min);
|
||||
}
|
||||
|
||||
public Set<Tuple> zrangeByScoreWithScores(String key, double min,
|
||||
double max, int offset, int count) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrangeByScoreWithScores(key, min, max, offset, count);
|
||||
}
|
||||
public Set<Tuple> zrevrangeByScoreWithScores(String key, double max,
|
||||
double min, int offset, int count) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrangeByScoreWithScores(key, max, min, offset, count);
|
||||
}
|
||||
|
||||
public Long zremrangeByRank(String key, int start, int end) {
|
||||
Jedis j = getShard(key);
|
||||
@@ -386,4 +404,4 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands {
|
||||
Jedis j = getShard(key);
|
||||
return j.linsert(key, where, pivot, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user