Merge branch 'support-sorted-set-with-lex' of https://github.com/HeartSaVioR/jedis into HeartSaVioR-support-sorted-set-with-lex
This commit is contained in:
@@ -7,6 +7,7 @@ import redis.clients.util.SafeEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import static redis.clients.jedis.Protocol.Command.*;
|
||||
@@ -827,6 +828,25 @@ public class BinaryClient extends Connection {
|
||||
args.addAll(params.getParams());
|
||||
sendCommand(ZINTERSTORE, args.toArray(new byte[args.size()][]));
|
||||
}
|
||||
|
||||
public void zlexcount(final byte[] key, final byte[] min, final byte[] max) {
|
||||
sendCommand(ZLEXCOUNT, key, min, max);
|
||||
}
|
||||
|
||||
public void zrangeByLex(final byte[] key, final byte[] min, final byte[] max) {
|
||||
sendCommand(ZRANGEBYLEX, key, min, max);
|
||||
}
|
||||
|
||||
public void zrangeByLex(final byte[] key, final byte[] min, final byte[] max,
|
||||
final int offset, final int count) {
|
||||
sendCommand(ZRANGEBYLEX, key, min, max, LIMIT.raw,
|
||||
toByteArray(offset), toByteArray(count));
|
||||
}
|
||||
|
||||
public void zremrangeByLex(byte[] key, byte[] min, byte[] max) {
|
||||
sendCommand(ZREMRANGEBYLEX, key, min, max);
|
||||
}
|
||||
|
||||
|
||||
public void save() {
|
||||
sendCommand(SAVE);
|
||||
|
||||
@@ -2812,6 +2812,35 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zlexcount(final byte[] key, final byte[] min, final byte[] max) {
|
||||
checkIsInMulti();
|
||||
client.zlexcount(key, min, max);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> zrangeByLex(final byte[] key, final byte[] min, final byte[] max) {
|
||||
checkIsInMulti();
|
||||
client.zrangeByLex(key, min, max);
|
||||
return new LinkedHashSet<byte[]>(client.getBinaryMultiBulkReply());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> zrangeByLex(final byte[] key, final byte[] min, final byte[] max,
|
||||
final int offset, final int count) {
|
||||
checkIsInMulti();
|
||||
client.zrangeByLex(key, min, max, offset, count);
|
||||
return new LinkedHashSet<byte[]>(client.getBinaryMultiBulkReply());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zremrangeByLex(final byte[] key, final byte[] min, final byte[] max) {
|
||||
checkIsInMulti();
|
||||
client.zremrangeByLex(key, min, max);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronously save the DB on disk.
|
||||
* <p>
|
||||
|
||||
@@ -196,6 +196,15 @@ public interface BinaryJedisCommands {
|
||||
Long zremrangeByScore(byte[] key, double start, double end);
|
||||
|
||||
Long zremrangeByScore(byte[] key, byte[] start, byte[] end);
|
||||
|
||||
Long zlexcount(final byte[] key, final byte[] min, final byte[] max);
|
||||
|
||||
Set<byte[]> zrangeByLex(final byte[] key, final byte[] min, final byte[] max);
|
||||
|
||||
Set<byte[]> zrangeByLex(final byte[] key, final byte[] min, final byte[] max,
|
||||
int offset, int count);
|
||||
|
||||
Long zremrangeByLex(final byte[] key, final byte[] min, final byte[] max);
|
||||
|
||||
Long linsert(byte[] key, Client.LIST_POSITION where, byte[] pivot,
|
||||
byte[] value);
|
||||
|
||||
@@ -206,6 +206,15 @@ public interface BinaryRedisPipeline {
|
||||
Response<Long> zrevrank(byte[] key, byte[] member);
|
||||
|
||||
Response<Double> zscore(byte[] key, byte[] member);
|
||||
|
||||
Response<Long> zlexcount(final byte[] key, final byte[] min, final byte[] max);
|
||||
|
||||
Response<Set<byte[]>> zrangeByLex(final byte[] key, final byte[] max, final byte[] min);
|
||||
|
||||
Response<Set<byte[]>> zrangeByLex(final byte[] key, final byte[] max, final byte[] min,
|
||||
int offset, int count);
|
||||
|
||||
Response<Long> zremrangeByLex(final byte[] key, final byte[] min, final byte[] max);
|
||||
|
||||
Response<Long> bitcount(byte[] key);
|
||||
|
||||
|
||||
@@ -490,6 +490,31 @@ public class BinaryShardedJedis extends Sharded<Jedis, JedisShardInfo>
|
||||
Jedis j = getShard(key);
|
||||
return j.zremrangeByScore(key, start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zlexcount(final byte[] key, final byte[] min, final byte[] max) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zlexcount(key, min, max);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> zrangeByLex(final byte[] key, final byte[] min, final byte[] max) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrangeByLex(key, min, max);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> zrangeByLex(final byte[] key, final byte[] min, final byte[] max,
|
||||
final int offset, final int count) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrangeByLex(key, min, max, offset, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zremrangeByLex(final byte[] key, final byte[] min, final byte[] max) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zremrangeByLex(key, min, max);
|
||||
}
|
||||
|
||||
public Long linsert(byte[] key, LIST_POSITION where, byte[] pivot,
|
||||
byte[] value) {
|
||||
|
||||
@@ -585,6 +585,24 @@ public class Client extends BinaryClient implements Commands {
|
||||
}
|
||||
zinterstore(SafeEncoder.encode(dstkey), params, bsets);
|
||||
}
|
||||
|
||||
public void zlexcount(final String key, final String min, final String max) {
|
||||
zlexcount(SafeEncoder.encode(key), SafeEncoder.encode(min), SafeEncoder.encode(max));
|
||||
}
|
||||
|
||||
public void zrangeByLex(final String key, final String min, final String max) {
|
||||
zrangeByLex(SafeEncoder.encode(key), SafeEncoder.encode(min), SafeEncoder.encode(max));
|
||||
}
|
||||
|
||||
public void zrangeByLex(final String key, final String min, final String max,
|
||||
final int offset, final int count) {
|
||||
zrangeByLex(SafeEncoder.encode(key), SafeEncoder.encode(min), SafeEncoder.encode(max),
|
||||
offset, count);
|
||||
}
|
||||
|
||||
public void zremrangeByLex(final String key, final String min, final String max) {
|
||||
zremrangeByLex(SafeEncoder.encode(key), SafeEncoder.encode(min), SafeEncoder.encode(max));
|
||||
}
|
||||
|
||||
public void strlen(final String key) {
|
||||
strlen(SafeEncoder.encode(key));
|
||||
|
||||
@@ -2609,6 +2609,35 @@ public class Jedis extends BinaryJedis implements JedisCommands,
|
||||
client.zinterstore(dstkey, params, sets);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zlexcount(final String key, final String min, final String max) {
|
||||
checkIsInMulti();
|
||||
client.zlexcount(key, min, max);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> zrangeByLex(final String key, final String min, final String max) {
|
||||
checkIsInMulti();
|
||||
client.zrangeByLex(key, min, max);
|
||||
return new LinkedHashSet<String>(client.getMultiBulkReply());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> zrangeByLex(final String key, final String min, final String max,
|
||||
final int offset, final int count) {
|
||||
checkIsInMulti();
|
||||
client.zrangeByLex(key, min, max, offset, count);
|
||||
return new LinkedHashSet<String>(client.getMultiBulkReply());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zremrangeByLex(final String key, final String min, final String max) {
|
||||
checkIsInMulti();
|
||||
client.zremrangeByLex(key, min, max);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public Long strlen(final String key) {
|
||||
client.strlen(key);
|
||||
@@ -3433,4 +3462,5 @@ public class Jedis extends BinaryJedis implements JedisCommands,
|
||||
client.pfmerge(destkey, sourcekeys);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1102,6 +1102,51 @@ public class JedisCluster implements JedisCommands, BasicCommands, Closeable {
|
||||
}
|
||||
}.run(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zlexcount(final String key, final String min, final String max) {
|
||||
return new JedisClusterCommand<Long>(connectionHandler, timeout,
|
||||
maxRedirections) {
|
||||
@Override
|
||||
public Long execute(Jedis connection) {
|
||||
return connection.zlexcount(key, min, max);
|
||||
}
|
||||
}.run(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> zrangeByLex(final String key, final String min, final String max) {
|
||||
return new JedisClusterCommand<Set<String>>(connectionHandler, timeout,
|
||||
maxRedirections) {
|
||||
@Override
|
||||
public Set<String> execute(Jedis connection) {
|
||||
return connection.zrangeByLex(key, min, max);
|
||||
}
|
||||
}.run(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> zrangeByLex(final String key, final String min, final String max,
|
||||
final int offset, final int count) {
|
||||
return new JedisClusterCommand<Set<String>>(connectionHandler, timeout,
|
||||
maxRedirections) {
|
||||
@Override
|
||||
public Set<String> execute(Jedis connection) {
|
||||
return connection.zrangeByLex(key, min, max, offset, count);
|
||||
}
|
||||
}.run(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zremrangeByLex(final String key, final String min, final String max) {
|
||||
return new JedisClusterCommand<Long>(connectionHandler, timeout,
|
||||
maxRedirections) {
|
||||
@Override
|
||||
public Long execute(Jedis connection) {
|
||||
return connection.zremrangeByLex(key, min, max);
|
||||
}
|
||||
}.run(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long linsert(final String key, final LIST_POSITION where,
|
||||
@@ -1490,4 +1535,5 @@ public class JedisCluster implements JedisCommands, BasicCommands, Closeable {
|
||||
}
|
||||
}.run(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -194,6 +194,15 @@ public interface JedisCommands {
|
||||
Long zremrangeByScore(String key, double start, double end);
|
||||
|
||||
Long zremrangeByScore(String key, String start, String end);
|
||||
|
||||
Long zlexcount(final String key, final String min, final String max);
|
||||
|
||||
Set<String> zrangeByLex(final String key, final String min, final String max);
|
||||
|
||||
Set<String> zrangeByLex(final String key, final String min, final String max,
|
||||
final int offset, final int count);
|
||||
|
||||
Long zremrangeByLex(final String key, final String min, final String max);
|
||||
|
||||
Long linsert(String key, Client.LIST_POSITION where, String pivot,
|
||||
String value);
|
||||
|
||||
@@ -1026,6 +1026,56 @@ abstract class PipelineBase extends Queable implements BinaryRedisPipeline,
|
||||
return getResponse(BuilderFactory.DOUBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response<Long> zlexcount(final byte[] key, final byte[] min, final byte[] max) {
|
||||
getClient(key).zlexcount(key, min, max);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response<Long> zlexcount(final String key, final String min, final String max) {
|
||||
getClient(key).zlexcount(key, min, max);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response<Set<byte[]>> zrangeByLex(final byte[] key, final byte[] max, final byte[] min) {
|
||||
getClient(key).zrangeByLex(key, min, max);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_ZSET);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response<Set<String>> zrangeByLex(final String key, final String max, final String min) {
|
||||
getClient(key).zrangeByLex(key, min, max);
|
||||
return getResponse(BuilderFactory.STRING_ZSET);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response<Set<byte[]>> zrangeByLex(final byte[] key, final byte[] max,
|
||||
final byte[] min, final int offset, final int count) {
|
||||
getClient(key).zrangeByLex(key, min, max, offset, count);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_ZSET);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response<Set<String>> zrangeByLex(final String key, final String max,
|
||||
final String min, final int offset, final int count) {
|
||||
getClient(key).zrangeByLex(key, min, max, offset, count);
|
||||
return getResponse(BuilderFactory.STRING_ZSET);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response<Long> zremrangeByLex(final byte[] key, final byte[] min, final byte[] max) {
|
||||
getClient(key).zremrangeByLex(key, min, max);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response<Long> zremrangeByLex(final String key, final String min, final String max) {
|
||||
getClient(key).zremrangeByLex(key, min, max);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> bitcount(String key) {
|
||||
getClient(key).bitcount(key);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
|
||||
@@ -218,7 +218,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, PUBSUB, 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, BITPOS, SETRANGE, GETRANGE, EVAL, EVALSHA, SCRIPT, SLOWLOG, OBJECT, BITCOUNT, BITOP, SENTINEL, DUMP, RESTORE, PEXPIRE, PEXPIREAT, PTTL, INCRBYFLOAT, PSETEX, CLIENT, TIME, MIGRATE, HINCRBYFLOAT, SCAN, HSCAN, SSCAN, ZSCAN, WAIT, CLUSTER, ASKING, PFADD, PFCOUNT, PFMERGE;
|
||||
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, PUBSUB, ZCOUNT, ZRANGEBYSCORE, ZREVRANGEBYSCORE, ZREMRANGEBYRANK, ZREMRANGEBYSCORE, ZUNIONSTORE, ZINTERSTORE, ZLEXCOUNT, ZRANGEBYLEX, ZREMRANGEBYLEX, SAVE, BGSAVE, BGREWRITEAOF, LASTSAVE, SHUTDOWN, INFO, MONITOR, SLAVEOF, CONFIG, STRLEN, SYNC, LPUSHX, PERSIST, RPUSHX, ECHO, LINSERT, DEBUG, BRPOPLPUSH, SETBIT, GETBIT, BITPOS, SETRANGE, GETRANGE, EVAL, EVALSHA, SCRIPT, SLOWLOG, OBJECT, BITCOUNT, BITOP, SENTINEL, DUMP, RESTORE, PEXPIRE, PEXPIREAT, PTTL, INCRBYFLOAT, PSETEX, CLIENT, TIME, MIGRATE, HINCRBYFLOAT, SCAN, HSCAN, SSCAN, ZSCAN, WAIT, CLUSTER, ASKING, PFADD, PFCOUNT, PFMERGE;
|
||||
|
||||
public final byte[] raw;
|
||||
|
||||
|
||||
@@ -184,6 +184,15 @@ public interface RedisPipeline {
|
||||
Response<Long> zrevrank(String key, String member);
|
||||
|
||||
Response<Double> zscore(String key, String member);
|
||||
|
||||
Response<Long> zlexcount(final String key, final String min, final String max);
|
||||
|
||||
Response<Set<String>> zrangeByLex(final String key, final String max, final String min);
|
||||
|
||||
Response<Set<String>> zrangeByLex(final String key, final String max, final String min,
|
||||
final int offset, final int count);
|
||||
|
||||
Response<Long> zremrangeByLex(final String key, final String start, final String end);
|
||||
|
||||
Response<Long> bitcount(String key);
|
||||
|
||||
|
||||
@@ -536,6 +536,27 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands,
|
||||
Jedis j = getShard(key);
|
||||
return j.zremrangeByScore(key, start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zlexcount(final String key, final String min, final String max) {
|
||||
return getShard(key).zlexcount(key, min, max);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> zrangeByLex(final String key, final String min, final String max) {
|
||||
return getShard(key).zrangeByLex(key, min, max);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> zrangeByLex(final String key, final String min, final String max,
|
||||
final int offset, final int count) {
|
||||
return getShard(key).zrangeByLex(key, min, max, offset, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zremrangeByLex(final String key, final String min, final String max) {
|
||||
return getShard(key).zremrangeByLex(key, min, max);
|
||||
}
|
||||
|
||||
public Long linsert(String key, LIST_POSITION where, String pivot,
|
||||
String value) {
|
||||
@@ -611,4 +632,5 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands,
|
||||
Jedis j = getShard(key);
|
||||
return j.pfcount(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user