Merge remote-tracking branch 'mindwind/master'
Conflicts: src/main/java/redis/clients/jedis/BinaryClient.java
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AdvancedBinaryJedisCommands {
|
||||
|
||||
List<byte[]> configGet(byte[] pattern);
|
||||
|
||||
byte[] configSet(byte[] parameter, byte[] value);
|
||||
|
||||
String slowlogReset();
|
||||
|
||||
Long slowlogLen();
|
||||
|
||||
List<byte[]> slowlogGetBinary();
|
||||
|
||||
List<byte[]> slowlogGetBinary(long entries);
|
||||
|
||||
Long objectRefcount(byte[] key);
|
||||
|
||||
byte[] objectEncoding(byte[] key);
|
||||
|
||||
Long objectIdletime(byte[] key);
|
||||
}
|
||||
26
src/main/java/redis/clients/jedis/AdvancedJedisCommands.java
Normal file
26
src/main/java/redis/clients/jedis/AdvancedJedisCommands.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
import redis.clients.util.Slowlog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface AdvancedJedisCommands {
|
||||
List<String> configGet(String pattern);
|
||||
|
||||
String configSet(String parameter, String value);
|
||||
|
||||
String slowlogReset();
|
||||
|
||||
Long slowlogLen();
|
||||
|
||||
List<Slowlog> slowlogGet();
|
||||
|
||||
List<Slowlog> slowlogGet(long entries);
|
||||
|
||||
Long objectRefcount(String string);
|
||||
|
||||
String objectEncoding(String string);
|
||||
|
||||
Long objectIdletime(String string);
|
||||
}
|
||||
42
src/main/java/redis/clients/jedis/BasicCommands.java
Normal file
42
src/main/java/redis/clients/jedis/BasicCommands.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
public interface BasicCommands {
|
||||
|
||||
String ping();
|
||||
|
||||
String quit();
|
||||
|
||||
String flushDB();
|
||||
|
||||
Long dbSize();
|
||||
|
||||
String select(int index);
|
||||
|
||||
String flushAll();
|
||||
|
||||
String auth(String password);
|
||||
|
||||
String save();
|
||||
|
||||
String bgsave();
|
||||
|
||||
String bgrewriteaof();
|
||||
|
||||
Long lastsave();
|
||||
|
||||
String shutdown();
|
||||
|
||||
String info();
|
||||
|
||||
String info(String section);
|
||||
|
||||
String slaveof(String host, int port);
|
||||
|
||||
String slaveofNoOne();
|
||||
|
||||
Long getDB();
|
||||
|
||||
String debug(DebugParams params);
|
||||
|
||||
String configResetStat();
|
||||
}
|
||||
38
src/main/java/redis/clients/jedis/BasicRedisPipeline.java
Normal file
38
src/main/java/redis/clients/jedis/BasicRedisPipeline.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Pipelined responses for all of the low level, non key related commands
|
||||
*/
|
||||
public interface BasicRedisPipeline {
|
||||
|
||||
Response<String> bgrewriteaof();
|
||||
|
||||
Response<String> bgsave();
|
||||
|
||||
Response<String> configGet(String pattern);
|
||||
|
||||
Response<String> configSet(String parameter, String value);
|
||||
|
||||
Response<String> configResetStat();
|
||||
|
||||
Response<String> save();
|
||||
|
||||
Response<Long> lastsave();
|
||||
|
||||
Response<String> flushDB();
|
||||
|
||||
Response<String> flushAll();
|
||||
|
||||
Response<String> info();
|
||||
|
||||
Response<Long> dbSize();
|
||||
|
||||
Response<String> shutdown();
|
||||
|
||||
Response<String> ping();
|
||||
|
||||
Response<String> select(int index);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -17,6 +17,8 @@ public interface BinaryJedisCommands {
|
||||
|
||||
Boolean exists(byte[] key);
|
||||
|
||||
Long persist(byte[] key);
|
||||
|
||||
String type(byte[] key);
|
||||
|
||||
Long expire(byte[] key, int seconds);
|
||||
@@ -25,6 +27,16 @@ public interface BinaryJedisCommands {
|
||||
|
||||
Long ttl(byte[] key);
|
||||
|
||||
Boolean setbit(byte[] key, long offset, boolean value);
|
||||
|
||||
Boolean setbit(byte[] key, long offset, byte[] value);
|
||||
|
||||
Boolean getbit(byte[] key, long offset);
|
||||
|
||||
Long setrange(byte[] key, long offset, byte[] value);
|
||||
|
||||
byte[] getrange(byte[] key, long startOffset, long endOffset);
|
||||
|
||||
byte[] getSet(byte[] key, byte[] value);
|
||||
|
||||
Long setnx(byte[] key, byte[] value);
|
||||
@@ -57,7 +69,7 @@ public interface BinaryJedisCommands {
|
||||
|
||||
Boolean hexists(byte[] key, byte[] field);
|
||||
|
||||
Long hdel(byte[] key, byte[] field);
|
||||
Long hdel(byte[] key, byte[]... field);
|
||||
|
||||
Long hlen(byte[] key);
|
||||
|
||||
@@ -67,31 +79,31 @@ public interface BinaryJedisCommands {
|
||||
|
||||
Map<byte[], byte[]> hgetAll(byte[] key);
|
||||
|
||||
Long rpush(byte[] key, byte[] string);
|
||||
Long rpush(byte[] key, byte[]... args);
|
||||
|
||||
Long lpush(byte[] key, byte[] string);
|
||||
Long lpush(byte[] key, byte[]... args);
|
||||
|
||||
Long llen(byte[] key);
|
||||
|
||||
List<byte[]> lrange(byte[] key, int start, int end);
|
||||
List<byte[]> lrange(byte[] key, long start, long end);
|
||||
|
||||
String ltrim(byte[] key, int start, int end);
|
||||
String ltrim(byte[] key, long start, long end);
|
||||
|
||||
byte[] lindex(byte[] key, int index);
|
||||
byte[] lindex(byte[] key, long index);
|
||||
|
||||
String lset(byte[] key, int index, byte[] value);
|
||||
String lset(byte[] key, long index, byte[] value);
|
||||
|
||||
Long lrem(byte[] key, int count, byte[] value);
|
||||
Long lrem(byte[] key, long count, byte[] value);
|
||||
|
||||
byte[] lpop(byte[] key);
|
||||
|
||||
byte[] rpop(byte[] key);
|
||||
|
||||
Long sadd(byte[] key, byte[] member);
|
||||
Long sadd(byte[] key, byte[]... member);
|
||||
|
||||
Set<byte[]> smembers(byte[] key);
|
||||
|
||||
Long srem(byte[] key, byte[] member);
|
||||
Long srem(byte[] key, byte[]... member);
|
||||
|
||||
byte[] spop(byte[] key);
|
||||
|
||||
@@ -101,11 +113,15 @@ public interface BinaryJedisCommands {
|
||||
|
||||
byte[] srandmember(byte[] key);
|
||||
|
||||
Long strlen(byte[] key);
|
||||
|
||||
Long zadd(byte[] key, double score, byte[] member);
|
||||
|
||||
Long zadd(byte[] key, Map<Double, byte[]> scoreMembers);
|
||||
|
||||
Set<byte[]> zrange(byte[] key, int start, int end);
|
||||
Set<byte[]> zrange(byte[] key, long start, long end);
|
||||
|
||||
Long zrem(byte[] key, byte[] member);
|
||||
Long zrem(byte[] key, byte[]... member);
|
||||
|
||||
Double zincrby(byte[] key, double score, byte[] member);
|
||||
|
||||
@@ -113,11 +129,11 @@ public interface BinaryJedisCommands {
|
||||
|
||||
Long zrevrank(byte[] key, byte[] member);
|
||||
|
||||
Set<byte[]> zrevrange(byte[] key, int start, int end);
|
||||
Set<byte[]> zrevrange(byte[] key, long start, long end);
|
||||
|
||||
Set<Tuple> zrangeWithScores(byte[] key, int start, int end);
|
||||
Set<Tuple> zrangeWithScores(byte[] key, long start, long end);
|
||||
|
||||
Set<Tuple> zrevrangeWithScores(byte[] key, int start, int end);
|
||||
Set<Tuple> zrevrangeWithScores(byte[] key, long start, long end);
|
||||
|
||||
Long zcard(byte[] key);
|
||||
|
||||
@@ -129,29 +145,72 @@ public interface BinaryJedisCommands {
|
||||
|
||||
Long zcount(byte[] key, double min, double max);
|
||||
|
||||
Long zcount(byte[] key, byte[] min, byte[] max);
|
||||
|
||||
Set<byte[]> zrangeByScore(byte[] key, double min, double max);
|
||||
|
||||
Set<byte[]> zrangeByScore(byte[] key, double min, double max, int offset,
|
||||
int count);
|
||||
|
||||
Set<Tuple> zrangeByScoreWithScores(byte[] key, double min, double max);
|
||||
|
||||
Set<Tuple> zrangeByScoreWithScores(byte[] key, double min, double max,
|
||||
int offset, int count);
|
||||
Set<byte[]> zrangeByScore(byte[] key, byte[] min, byte[] max);
|
||||
|
||||
Set<byte[]> zrevrangeByScore(byte[] key, double max, double min);
|
||||
|
||||
Set<byte[]> zrevrangeByScore(byte[] key, double max, double min, int offset,
|
||||
Set<byte[]> zrangeByScore(byte[] key, double min, double max, int offset,
|
||||
int count);
|
||||
|
||||
Set<byte[]> zrevrangeByScore(byte[] key, byte[] max, byte[] min);
|
||||
|
||||
Set<byte[]> zrangeByScore(byte[] key, byte[] min, byte[] max, int offset,
|
||||
int count);
|
||||
|
||||
Set<byte[]> zrevrangeByScore(byte[] key, double max, double min,
|
||||
int offset, int count);
|
||||
|
||||
Set<Tuple> zrangeByScoreWithScores(byte[] key, double min, double max);
|
||||
|
||||
Set<Tuple> zrevrangeByScoreWithScores(byte[] key, double max, double min);
|
||||
|
||||
Set<Tuple> zrevrangeByScoreWithScores(byte[] key, double max, double min,
|
||||
Set<Tuple> zrangeByScoreWithScores(byte[] key, double min, double max,
|
||||
int offset, int count);
|
||||
|
||||
Set<byte[]> zrevrangeByScore(byte[] key, byte[] max, byte[] min,
|
||||
int offset, int count);
|
||||
|
||||
Long zremrangeByRank(byte[] key, int start, int end);
|
||||
Set<Tuple> zrangeByScoreWithScores(byte[] key, byte[] min, byte[] max);
|
||||
|
||||
Set<Tuple> zrevrangeByScoreWithScores(byte[] key, byte[] max, byte[] min);
|
||||
|
||||
Set<Tuple> zrangeByScoreWithScores(byte[] key, byte[] min, byte[] max,
|
||||
int offset, int count);
|
||||
|
||||
Set<Tuple> zrevrangeByScoreWithScores(byte[] key, double max, double min,
|
||||
int offset, int count);
|
||||
|
||||
Set<Tuple> zrevrangeByScoreWithScores(byte[] key, byte[] max, byte[] min,
|
||||
int offset, int count);
|
||||
|
||||
Long zremrangeByRank(byte[] key, long start, long end);
|
||||
|
||||
Long zremrangeByScore(byte[] key, double start, double end);
|
||||
|
||||
Long zremrangeByScore(byte[] key, byte[] start, byte[] end);
|
||||
|
||||
Long linsert(byte[] key, LIST_POSITION where, byte[] pivot, byte[] value);
|
||||
Long linsert(byte[] key, Client.LIST_POSITION where, byte[] pivot,
|
||||
byte[] value);
|
||||
|
||||
Long lpushx(byte[] key, byte[]... arg);
|
||||
|
||||
Long rpushx(byte[] key, byte[]... arg);
|
||||
|
||||
List<byte[]> blpop(byte[] arg);
|
||||
|
||||
List<byte[]> brpop(byte[] arg);
|
||||
|
||||
Long del(byte[] key);
|
||||
|
||||
byte[] echo(byte[] arg);
|
||||
|
||||
Long move(byte[] key, int dbIndex);
|
||||
|
||||
Long bitcount(final byte[] key);
|
||||
|
||||
Long bitcount(final byte[] key, long start, long end);
|
||||
}
|
||||
|
||||
219
src/main/java/redis/clients/jedis/BinaryRedisPipeline.java
Normal file
219
src/main/java/redis/clients/jedis/BinaryRedisPipeline.java
Normal file
@@ -0,0 +1,219 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author guy
|
||||
*/
|
||||
public interface BinaryRedisPipeline {
|
||||
Response<Long> append(byte[] key, byte[] value);
|
||||
|
||||
Response<List<byte[]>> blpop(byte[] arg);
|
||||
|
||||
Response<List<byte[]>> brpop(byte[] arg);
|
||||
|
||||
Response<Long> decr(byte[] key);
|
||||
|
||||
Response<Long> decrBy(byte[] key, long integer);
|
||||
|
||||
Response<Long> del(byte[] keys);
|
||||
|
||||
Response<byte[]> echo(byte[] string);
|
||||
|
||||
Response<Boolean> exists(byte[] key);
|
||||
|
||||
Response<Long> expire(byte[] key, int seconds);
|
||||
|
||||
Response<Long> expireAt(byte[] key, long unixTime);
|
||||
|
||||
Response<byte[]> get(byte[] key);
|
||||
|
||||
Response<Boolean> getbit(byte[] key, long offset);
|
||||
|
||||
Response<byte[]> getSet(byte[] key, byte[] value);
|
||||
|
||||
Response<Long> getrange(byte[] key, long startOffset, long endOffset);
|
||||
|
||||
Response<Long> hdel(byte[] key, byte[]... field);
|
||||
|
||||
Response<Boolean> hexists(byte[] key, byte[] field);
|
||||
|
||||
Response<byte[]> hget(byte[] key, byte[] field);
|
||||
|
||||
Response<Map<byte[], byte[]>> hgetAll(byte[] key);
|
||||
|
||||
Response<Long> hincrBy(byte[] key, byte[] field, long value);
|
||||
|
||||
Response<Set<byte[]>> hkeys(byte[] key);
|
||||
|
||||
Response<Long> hlen(byte[] key);
|
||||
|
||||
Response<List<byte[]>> hmget(byte[] key, byte[]... fields);
|
||||
|
||||
Response<String> hmset(byte[] key, Map<byte[], byte[]> hash);
|
||||
|
||||
Response<Long> hset(byte[] key, byte[] field, byte[] value);
|
||||
|
||||
Response<Long> hsetnx(byte[] key, byte[] field, byte[] value);
|
||||
|
||||
Response<List<byte[]>> hvals(byte[] key);
|
||||
|
||||
Response<Long> incr(byte[] key);
|
||||
|
||||
Response<Long> incrBy(byte[] key, long integer);
|
||||
|
||||
Response<byte[]> lindex(byte[] key, long index);
|
||||
|
||||
Response<Long> linsert(byte[] key, BinaryClient.LIST_POSITION where,
|
||||
byte[] pivot, byte[] value);
|
||||
|
||||
Response<Long> llen(byte[] key);
|
||||
|
||||
Response<byte[]> lpop(byte[] key);
|
||||
|
||||
Response<Long> lpush(byte[] key, byte[]... string);
|
||||
|
||||
Response<Long> lpushx(byte[] key, byte[]... bytes);
|
||||
|
||||
Response<List<byte[]>> lrange(byte[] key, long start, long end);
|
||||
|
||||
Response<Long> lrem(byte[] key, long count, byte[] value);
|
||||
|
||||
Response<String> lset(byte[] key, long index, byte[] value);
|
||||
|
||||
Response<String> ltrim(byte[] key, long start, long end);
|
||||
|
||||
Response<Long> move(byte[] key, int dbIndex);
|
||||
|
||||
Response<Long> persist(byte[] key);
|
||||
|
||||
Response<byte[]> rpop(byte[] key);
|
||||
|
||||
Response<Long> rpush(byte[] key, byte[]... string);
|
||||
|
||||
Response<Long> rpushx(byte[] key, byte[]... string);
|
||||
|
||||
Response<Long> sadd(byte[] key, byte[]... member);
|
||||
|
||||
Response<Long> scard(byte[] key);
|
||||
|
||||
Response<String> set(byte[] key, byte[] value);
|
||||
|
||||
Response<Boolean> setbit(byte[] key, long offset, byte[] value);
|
||||
|
||||
Response<Long> setrange(byte[] key, long offset, byte[] value);
|
||||
|
||||
Response<String> setex(byte[] key, int seconds, byte[] value);
|
||||
|
||||
Response<Long> setnx(byte[] key, byte[] value);
|
||||
|
||||
Response<Long> setrange(String key, long offset, String value);
|
||||
|
||||
Response<Set<byte[]>> smembers(byte[] key);
|
||||
|
||||
Response<Boolean> sismember(byte[] key, byte[] member);
|
||||
|
||||
Response<List<byte[]>> sort(byte[] key);
|
||||
|
||||
Response<List<byte[]>> sort(byte[] key,
|
||||
SortingParams sortingParameters);
|
||||
|
||||
Response<byte[]> spop(byte[] key);
|
||||
|
||||
Response<byte[]> srandmember(byte[] key);
|
||||
|
||||
Response<Long> srem(byte[] key, byte[]... member);
|
||||
|
||||
Response<Long> strlen(byte[] key);
|
||||
|
||||
Response<String> substr(byte[] key, int start, int end);
|
||||
|
||||
Response<Long> ttl(byte[] key);
|
||||
|
||||
Response<String> type(byte[] key);
|
||||
|
||||
Response<Long> zadd(byte[] key, double score, byte[] member);
|
||||
|
||||
Response<Long> zcard(byte[] key);
|
||||
|
||||
Response<Long> zcount(byte[] key, double min, double max);
|
||||
|
||||
Response<Double> zincrby(byte[] key, double score, byte[] member);
|
||||
|
||||
Response<Set<byte[]>> zrange(byte[] key, long start, long end);
|
||||
|
||||
Response<Set<byte[]>> zrangeByScore(byte[] key, double min,
|
||||
double max);
|
||||
|
||||
Response<Set<byte[]>> zrangeByScore(byte[] key, byte[] min,
|
||||
byte[] max);
|
||||
|
||||
Response<Set<byte[]>> zrangeByScore(byte[] key, double min,
|
||||
double max, int offset, int count);
|
||||
|
||||
Response<Set<byte[]>> zrangeByScore(byte[] key, byte[] min,
|
||||
byte[] max, int offset, int count);
|
||||
|
||||
Response<Set<Tuple>> zrangeByScoreWithScores(byte[] key, double min,
|
||||
double max);
|
||||
|
||||
Response<Set<Tuple>> zrangeByScoreWithScores(byte[] key, byte[] min,
|
||||
byte[] max);
|
||||
|
||||
Response<Set<Tuple>> zrangeByScoreWithScores(byte[] key, double min,
|
||||
double max, int offset, int count);
|
||||
|
||||
Response<Set<Tuple>> zrangeByScoreWithScores(byte[] key, byte[] min,
|
||||
byte[] max, int offset, int count);
|
||||
|
||||
Response<Set<byte[]>> zrevrangeByScore(byte[] key, double max,
|
||||
double min);
|
||||
|
||||
Response<Set<byte[]>> zrevrangeByScore(byte[] key, byte[] max,
|
||||
byte[] min);
|
||||
|
||||
Response<Set<byte[]>> zrevrangeByScore(byte[] key, double max,
|
||||
double min, int offset, int count);
|
||||
|
||||
Response<Set<byte[]>> zrevrangeByScore(byte[] key, byte[] max,
|
||||
byte[] min, int offset, int count);
|
||||
|
||||
Response<Set<Tuple>> zrevrangeByScoreWithScores(byte[] key,
|
||||
double max, double min);
|
||||
|
||||
Response<Set<Tuple>> zrevrangeByScoreWithScores(byte[] key,
|
||||
byte[] max, byte[] min);
|
||||
|
||||
Response<Set<Tuple>> zrevrangeByScoreWithScores(byte[] key,
|
||||
double max, double min, int offset, int count);
|
||||
|
||||
Response<Set<Tuple>> zrevrangeByScoreWithScores(byte[] key,
|
||||
byte[] max, byte[] min, int offset, int count);
|
||||
|
||||
Response<Set<Tuple>> zrangeWithScores(byte[] key, long start, long end);
|
||||
|
||||
Response<Long> zrank(byte[] key, byte[] member);
|
||||
|
||||
Response<Long> zrem(byte[] key, byte[]... member);
|
||||
|
||||
Response<Long> zremrangeByRank(byte[] key, long start, long end);
|
||||
|
||||
Response<Long> zremrangeByScore(byte[] key, double start, double end);
|
||||
|
||||
Response<Long> zremrangeByScore(byte[] key, byte[] start, byte[] end);
|
||||
|
||||
Response<Set<byte[]>> zrevrange(byte[] key, long start, long end);
|
||||
|
||||
Response<Set<Tuple>> zrevrangeWithScores(byte[] key, long start,
|
||||
long end);
|
||||
|
||||
Response<Long> zrevrank(byte[] key, byte[] member);
|
||||
|
||||
Response<Double> zscore(byte[] key, byte[] member);
|
||||
|
||||
Response<Long> bitcount(byte[] key);
|
||||
|
||||
Response<Long> bitcount(byte[] key, long start, long end);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface BinaryScriptingCommands {
|
||||
|
||||
Object eval(byte[] script, byte[] keyCount, byte[]... params);
|
||||
|
||||
Object eval(byte[] script, int keyCount, byte[]... params);
|
||||
|
||||
Object eval(byte[] script, List<byte[]> keys, List<byte[]> args);
|
||||
|
||||
Object eval(byte[] script);
|
||||
|
||||
Object evalsha(byte[] script);
|
||||
|
||||
Object evalsha(byte[] sha1, List<byte[]> keys, List<byte[]> args);
|
||||
|
||||
Object evalsha(byte[] sha1, int keyCount, byte[]... params);
|
||||
|
||||
// TODO: should be Boolean, add singular version
|
||||
List<Long> scriptExists(byte[]... sha1);
|
||||
|
||||
byte[] scriptLoad(byte[] script);
|
||||
|
||||
String scriptFlush();
|
||||
|
||||
String scriptKill();
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
import redis.clients.jedis.BinaryClient.LIST_POSITION;
|
||||
import redis.clients.util.Hashing;
|
||||
import redis.clients.util.Sharded;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -7,397 +11,556 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import redis.clients.jedis.BinaryClient.LIST_POSITION;
|
||||
import redis.clients.util.Hashing;
|
||||
import redis.clients.util.Sharded;
|
||||
|
||||
public class BinaryShardedJedis extends Sharded<Jedis, JedisShardInfo>
|
||||
implements BinaryJedisCommands {
|
||||
implements BinaryJedisCommands {
|
||||
public BinaryShardedJedis(List<JedisShardInfo> shards) {
|
||||
super(shards);
|
||||
super(shards);
|
||||
}
|
||||
|
||||
public BinaryShardedJedis(List<JedisShardInfo> shards, Hashing algo) {
|
||||
super(shards, algo);
|
||||
super(shards, algo);
|
||||
}
|
||||
|
||||
public BinaryShardedJedis(List<JedisShardInfo> shards, Pattern keyTagPattern) {
|
||||
super(shards, keyTagPattern);
|
||||
super(shards, keyTagPattern);
|
||||
}
|
||||
|
||||
public BinaryShardedJedis(List<JedisShardInfo> shards, Hashing algo,
|
||||
Pattern keyTagPattern) {
|
||||
super(shards, algo, keyTagPattern);
|
||||
Pattern keyTagPattern) {
|
||||
super(shards, algo, keyTagPattern);
|
||||
}
|
||||
|
||||
public void disconnect() throws IOException {
|
||||
for (Jedis jedis : getAllShards()) {
|
||||
jedis.disconnect();
|
||||
}
|
||||
public void disconnect() {
|
||||
for (Jedis jedis : getAllShards()) {
|
||||
jedis.quit();
|
||||
jedis.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
protected Jedis create(JedisShardInfo shard) {
|
||||
return new Jedis(shard);
|
||||
return new Jedis(shard);
|
||||
}
|
||||
|
||||
public String set(byte[] key, byte[] value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.set(key, value);
|
||||
Jedis j = getShard(key);
|
||||
return j.set(key, value);
|
||||
}
|
||||
|
||||
public byte[] get(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.get(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.get(key);
|
||||
}
|
||||
|
||||
public Boolean exists(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.exists(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.exists(key);
|
||||
}
|
||||
|
||||
public String type(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.type(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.type(key);
|
||||
}
|
||||
|
||||
public Long expire(byte[] key, int seconds) {
|
||||
Jedis j = getShard(key);
|
||||
return j.expire(key, seconds);
|
||||
Jedis j = getShard(key);
|
||||
return j.expire(key, seconds);
|
||||
}
|
||||
|
||||
public Long expireAt(byte[] key, long unixTime) {
|
||||
Jedis j = getShard(key);
|
||||
return j.expireAt(key, unixTime);
|
||||
Jedis j = getShard(key);
|
||||
return j.expireAt(key, unixTime);
|
||||
}
|
||||
|
||||
public Long ttl(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.ttl(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.ttl(key);
|
||||
}
|
||||
|
||||
public byte[] getSet(byte[] key, byte[] value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.getSet(key, value);
|
||||
Jedis j = getShard(key);
|
||||
return j.getSet(key, value);
|
||||
}
|
||||
|
||||
public Long setnx(byte[] key, byte[] value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.setnx(key, value);
|
||||
Jedis j = getShard(key);
|
||||
return j.setnx(key, value);
|
||||
}
|
||||
|
||||
public String setex(byte[] key, int seconds, byte[] value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.setex(key, seconds, value);
|
||||
Jedis j = getShard(key);
|
||||
return j.setex(key, seconds, value);
|
||||
}
|
||||
|
||||
public Long decrBy(byte[] key, long integer) {
|
||||
Jedis j = getShard(key);
|
||||
return j.decrBy(key, integer);
|
||||
Jedis j = getShard(key);
|
||||
return j.decrBy(key, integer);
|
||||
}
|
||||
|
||||
public Long decr(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.decr(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.decr(key);
|
||||
}
|
||||
|
||||
public Long incrBy(byte[] key, long integer) {
|
||||
public Long del(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.incrBy(key, integer);
|
||||
return j.del(key);
|
||||
}
|
||||
|
||||
public Long incrBy(byte[] key, long integer) {
|
||||
Jedis j = getShard(key);
|
||||
return j.incrBy(key, integer);
|
||||
}
|
||||
|
||||
public Long incr(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.incr(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.incr(key);
|
||||
}
|
||||
|
||||
public Long append(byte[] key, byte[] value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.append(key, value);
|
||||
Jedis j = getShard(key);
|
||||
return j.append(key, value);
|
||||
}
|
||||
|
||||
public byte[] substr(byte[] key, int start, int end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.substr(key, start, end);
|
||||
Jedis j = getShard(key);
|
||||
return j.substr(key, start, end);
|
||||
}
|
||||
|
||||
public Long hset(byte[] key, byte[] field, byte[] value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hset(key, field, value);
|
||||
Jedis j = getShard(key);
|
||||
return j.hset(key, field, value);
|
||||
}
|
||||
|
||||
public byte[] hget(byte[] key, byte[] field) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hget(key, field);
|
||||
Jedis j = getShard(key);
|
||||
return j.hget(key, field);
|
||||
}
|
||||
|
||||
public Long hsetnx(byte[] key, byte[] field, byte[] value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hsetnx(key, field, value);
|
||||
Jedis j = getShard(key);
|
||||
return j.hsetnx(key, field, value);
|
||||
}
|
||||
|
||||
public String hmset(byte[] key, Map<byte[], byte[]> hash) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hmset(key, hash);
|
||||
Jedis j = getShard(key);
|
||||
return j.hmset(key, hash);
|
||||
}
|
||||
|
||||
public List<byte[]> hmget(byte[] key, byte[]... fields) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hmget(key, fields);
|
||||
Jedis j = getShard(key);
|
||||
return j.hmget(key, fields);
|
||||
}
|
||||
|
||||
public Long hincrBy(byte[] key, byte[] field, long value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hincrBy(key, field, value);
|
||||
Jedis j = getShard(key);
|
||||
return j.hincrBy(key, field, value);
|
||||
}
|
||||
|
||||
public Boolean hexists(byte[] key, byte[] field) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hexists(key, field);
|
||||
Jedis j = getShard(key);
|
||||
return j.hexists(key, field);
|
||||
}
|
||||
|
||||
public Long hdel(byte[] key, byte[] field) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hdel(key, field);
|
||||
public Long hdel(byte[] key, byte[]... fields) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hdel(key, fields);
|
||||
}
|
||||
|
||||
public Long hlen(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hlen(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.hlen(key);
|
||||
}
|
||||
|
||||
public Set<byte[]> hkeys(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hkeys(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.hkeys(key);
|
||||
}
|
||||
|
||||
public Collection<byte[]> hvals(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hvals(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.hvals(key);
|
||||
}
|
||||
|
||||
public Map<byte[], byte[]> hgetAll(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hgetAll(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.hgetAll(key);
|
||||
}
|
||||
|
||||
public Long rpush(byte[] key, byte[] string) {
|
||||
Jedis j = getShard(key);
|
||||
return j.rpush(key, string);
|
||||
public Long rpush(byte[] key, byte[]... strings) {
|
||||
Jedis j = getShard(key);
|
||||
return j.rpush(key, strings);
|
||||
}
|
||||
|
||||
public Long lpush(byte[] key, byte[] string) {
|
||||
public Long lpush(byte[] key, byte[]... strings) {
|
||||
Jedis j = getShard(key);
|
||||
return j.lpush(key, strings);
|
||||
}
|
||||
|
||||
public Long strlen(final byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.strlen(key);
|
||||
}
|
||||
|
||||
public Long lpushx(byte[] key, byte[]... string) {
|
||||
Jedis j = getShard(key);
|
||||
return j.lpush(key, string);
|
||||
return j.lpushx(key, string);
|
||||
}
|
||||
|
||||
public Long persist(final byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.persist(key);
|
||||
}
|
||||
|
||||
public Long rpushx(byte[] key, byte[]... string) {
|
||||
Jedis j = getShard(key);
|
||||
return j.rpushx(key, string);
|
||||
}
|
||||
|
||||
public Long llen(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.llen(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.llen(key);
|
||||
}
|
||||
|
||||
public List<byte[]> lrange(byte[] key, int start, int end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.lrange(key, start, end);
|
||||
public List<byte[]> lrange(byte[] key, long start, long end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.lrange(key, start, end);
|
||||
}
|
||||
|
||||
public String ltrim(byte[] key, int start, int end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.ltrim(key, start, end);
|
||||
public String ltrim(byte[] key, long start, long end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.ltrim(key, start, end);
|
||||
}
|
||||
|
||||
public byte[] lindex(byte[] key, int index) {
|
||||
Jedis j = getShard(key);
|
||||
return j.lindex(key, index);
|
||||
public byte[] lindex(byte[] key, long index) {
|
||||
Jedis j = getShard(key);
|
||||
return j.lindex(key, index);
|
||||
}
|
||||
|
||||
public String lset(byte[] key, int index, byte[] value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.lset(key, index, value);
|
||||
public String lset(byte[] key, long index, byte[] value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.lset(key, index, value);
|
||||
}
|
||||
|
||||
public Long lrem(byte[] key, int count, byte[] value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.lrem(key, count, value);
|
||||
public Long lrem(byte[] key, long count, byte[] value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.lrem(key, count, value);
|
||||
}
|
||||
|
||||
public byte[] lpop(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.lpop(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.lpop(key);
|
||||
}
|
||||
|
||||
public byte[] rpop(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.rpop(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.rpop(key);
|
||||
}
|
||||
|
||||
public Long sadd(byte[] key, byte[] member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.sadd(key, member);
|
||||
public Long sadd(byte[] key, byte[]... members) {
|
||||
Jedis j = getShard(key);
|
||||
return j.sadd(key, members);
|
||||
}
|
||||
|
||||
public Set<byte[]> smembers(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.smembers(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.smembers(key);
|
||||
}
|
||||
|
||||
public Long srem(byte[] key, byte[] member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.srem(key, member);
|
||||
public Long srem(byte[] key, byte[]... members) {
|
||||
Jedis j = getShard(key);
|
||||
return j.srem(key, members);
|
||||
}
|
||||
|
||||
public byte[] spop(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.spop(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.spop(key);
|
||||
}
|
||||
|
||||
public Long scard(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.scard(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.scard(key);
|
||||
}
|
||||
|
||||
public Boolean sismember(byte[] key, byte[] member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.sismember(key, member);
|
||||
Jedis j = getShard(key);
|
||||
return j.sismember(key, member);
|
||||
}
|
||||
|
||||
public byte[] srandmember(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.srandmember(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.srandmember(key);
|
||||
}
|
||||
|
||||
public Long zadd(byte[] key, double score, byte[] member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zadd(key, score, member);
|
||||
Jedis j = getShard(key);
|
||||
return j.zadd(key, score, member);
|
||||
}
|
||||
|
||||
public Set<byte[]> zrange(byte[] key, int start, int end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrange(key, start, end);
|
||||
public Long zadd(byte[] key, Map<Double, byte[]> scoreMembers) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zadd(key, scoreMembers);
|
||||
}
|
||||
|
||||
public Long zrem(byte[] key, byte[] member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrem(key, member);
|
||||
public Set<byte[]> zrange(byte[] key, long start, long end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrange(key, start, end);
|
||||
}
|
||||
|
||||
public Long zrem(byte[] key, byte[]... members) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrem(key, members);
|
||||
}
|
||||
|
||||
public Double zincrby(byte[] key, double score, byte[] member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zincrby(key, score, member);
|
||||
Jedis j = getShard(key);
|
||||
return j.zincrby(key, score, member);
|
||||
}
|
||||
|
||||
public Long zrank(byte[] key, byte[] member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrank(key, member);
|
||||
Jedis j = getShard(key);
|
||||
return j.zrank(key, member);
|
||||
}
|
||||
|
||||
public Long zrevrank(byte[] key, byte[] member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrank(key, member);
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrank(key, member);
|
||||
}
|
||||
|
||||
public Set<byte[]> zrevrange(byte[] key, int start, int end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrange(key, start, end);
|
||||
public Set<byte[]> zrevrange(byte[] key, long start, long end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrange(key, start, end);
|
||||
}
|
||||
|
||||
public Set<Tuple> zrangeWithScores(byte[] key, int start, int end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrangeWithScores(key, start, end);
|
||||
public Set<Tuple> zrangeWithScores(byte[] key, long start, long end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrangeWithScores(key, start, end);
|
||||
}
|
||||
|
||||
public Set<Tuple> zrevrangeWithScores(byte[] key, int start, int end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrangeWithScores(key, start, end);
|
||||
public Set<Tuple> zrevrangeWithScores(byte[] key, long start, long end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrangeWithScores(key, start, end);
|
||||
}
|
||||
|
||||
public Long zcard(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zcard(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.zcard(key);
|
||||
}
|
||||
|
||||
public Double zscore(byte[] key, byte[] member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zscore(key, member);
|
||||
Jedis j = getShard(key);
|
||||
return j.zscore(key, member);
|
||||
}
|
||||
|
||||
public List<byte[]> sort(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.sort(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.sort(key);
|
||||
}
|
||||
|
||||
public List<byte[]> sort(byte[] key, SortingParams sortingParameters) {
|
||||
Jedis j = getShard(key);
|
||||
return j.sort(key, sortingParameters);
|
||||
Jedis j = getShard(key);
|
||||
return j.sort(key, sortingParameters);
|
||||
}
|
||||
|
||||
public Long zcount(byte[] key, double min, double max) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zcount(key, min, max);
|
||||
Jedis j = getShard(key);
|
||||
return j.zcount(key, min, max);
|
||||
}
|
||||
|
||||
public Long zcount(byte[] key, byte[] min, byte[] max) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zcount(key, min, max);
|
||||
}
|
||||
|
||||
public Set<byte[]> zrangeByScore(byte[] key, double min, double max) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrangeByScore(key, min, max);
|
||||
}
|
||||
|
||||
public Set<byte[]> zrangeByScore(byte[] key, double min, double max,
|
||||
int offset, int count) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrangeByScore(key, min, max, offset, count);
|
||||
}
|
||||
|
||||
public Set<Tuple> zrangeByScoreWithScores(byte[] key, double min, double max) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrangeByScoreWithScores(key, min, max);
|
||||
}
|
||||
|
||||
public Set<Tuple> zrangeByScoreWithScores(byte[] key, double min,
|
||||
double max, int offset, int count) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrangeByScoreWithScores(key, min, max, offset, count);
|
||||
}
|
||||
|
||||
public Set<byte[]> zrangeByScore(byte[] key, byte[] min, byte[] max) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrangeByScore(key, min, max);
|
||||
}
|
||||
|
||||
public Set<byte[]> zrangeByScore(byte[] key, double min, double max,
|
||||
int offset, int count) {
|
||||
public Set<Tuple> zrangeByScoreWithScores(byte[] key, byte[] min, byte[] max) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrangeByScoreWithScores(key, min, max);
|
||||
}
|
||||
|
||||
public Set<Tuple> zrangeByScoreWithScores(byte[] key, byte[] min,
|
||||
byte[] max, int offset, int count) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrangeByScoreWithScores(key, min, max, offset, count);
|
||||
}
|
||||
|
||||
public Set<byte[]> zrangeByScore(byte[] key, byte[] min, byte[] max, int offset, int count) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrangeByScore(key, min, max, offset, count);
|
||||
}
|
||||
|
||||
public Set<Tuple> zrangeByScoreWithScores(byte[] key, double min, double max) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrangeByScoreWithScores(key, min, max);
|
||||
}
|
||||
|
||||
public Set<Tuple> zrangeByScoreWithScores(byte[] key, double min,
|
||||
double max, int offset, int count) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrangeByScoreWithScores(key, min, max, offset, count);
|
||||
}
|
||||
|
||||
public Set<byte[]> zrevrangeByScore(byte[] key, double max, double min) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrangeByScore(key, max, min);
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrangeByScore(key, max, min);
|
||||
}
|
||||
|
||||
public Set<byte[]> zrevrangeByScore(byte[] key, double max, double min,
|
||||
int offset, int count) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrangeByScore(key, max, min, offset, count);
|
||||
}
|
||||
|
||||
public Set<Tuple> zrevrangeByScoreWithScores(byte[] key, double max, double min) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrangeByScoreWithScores(key, max, min);
|
||||
int offset, int count) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrangeByScore(key, max, min, offset, count);
|
||||
}
|
||||
|
||||
public Set<Tuple> zrevrangeByScoreWithScores(byte[] key, double max,
|
||||
double min, int offset, int count) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrangeByScoreWithScores(key, max, min, offset, count);
|
||||
double min) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrangeByScoreWithScores(key, max, min);
|
||||
}
|
||||
|
||||
public Long zremrangeByRank(byte[] key, int start, int end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zremrangeByRank(key, start, end);
|
||||
public Set<Tuple> zrevrangeByScoreWithScores(byte[] key, double max,
|
||||
double min, int offset, int count) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrangeByScoreWithScores(key, max, min, offset, count);
|
||||
}
|
||||
|
||||
public Set<byte[]> zrevrangeByScore(byte[] key, byte[] max, byte[] min) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrangeByScore(key, max, min);
|
||||
}
|
||||
|
||||
public Set<byte[]> zrevrangeByScore(byte[] key, byte[] max, byte[] min,
|
||||
int offset, int count) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrangeByScore(key, max, min, offset, count);
|
||||
}
|
||||
|
||||
public Set<Tuple> zrevrangeByScoreWithScores(byte[] key, byte[] max,
|
||||
byte[] min) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrangeByScoreWithScores(key, max, min);
|
||||
}
|
||||
|
||||
public Set<Tuple> zrevrangeByScoreWithScores(byte[] key, byte[] max,
|
||||
byte[] min, int offset, int count) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrangeByScoreWithScores(key, max, min, offset, count);
|
||||
}
|
||||
|
||||
public Long zremrangeByRank(byte[] key, long start, long end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zremrangeByRank(key, start, end);
|
||||
}
|
||||
|
||||
public Long zremrangeByScore(byte[] key, double start, double end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zremrangeByScore(key, start, end);
|
||||
Jedis j = getShard(key);
|
||||
return j.zremrangeByScore(key, start, end);
|
||||
}
|
||||
|
||||
public Long zremrangeByScore(byte[] key, byte[] start, byte[] end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zremrangeByScore(key, start, end);
|
||||
}
|
||||
|
||||
public Long linsert(byte[] key, LIST_POSITION where, byte[] pivot,
|
||||
byte[] value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.linsert(key, where, pivot, value);
|
||||
byte[] value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.linsert(key, where, pivot, value);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public List<Object> pipelined(ShardedJedisPipeline shardedJedisPipeline) {
|
||||
shardedJedisPipeline.setShardedJedis(this);
|
||||
shardedJedisPipeline.execute();
|
||||
return shardedJedisPipeline.getResults();
|
||||
shardedJedisPipeline.setShardedJedis(this);
|
||||
shardedJedisPipeline.execute();
|
||||
return shardedJedisPipeline.getResults();
|
||||
}
|
||||
|
||||
public ShardedJedisPipeline pipelined() {
|
||||
ShardedJedisPipeline pipeline = new ShardedJedisPipeline();
|
||||
pipeline.setShardedJedis(this);
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
public Long objectRefcount(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.objectRefcount(key);
|
||||
}
|
||||
|
||||
public byte[] objectEncoding(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.objectEncoding(key);
|
||||
}
|
||||
|
||||
public Long objectIdletime(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.objectIdletime(key);
|
||||
}
|
||||
|
||||
public Boolean setbit(byte[] key, long offset, boolean value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.setbit(key, offset, value);
|
||||
}
|
||||
|
||||
public Boolean setbit(byte[] key, long offset, byte[] value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.setbit(key, offset, value);
|
||||
}
|
||||
|
||||
public Boolean getbit(byte[] key, long offset) {
|
||||
Jedis j = getShard(key);
|
||||
return j.getbit(key, offset);
|
||||
}
|
||||
|
||||
public Long setrange(byte[] key, long offset, byte[] value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.setrange(key, offset, value);
|
||||
}
|
||||
|
||||
public byte[] getrange(byte[] key, long startOffset, long endOffset) {
|
||||
Jedis j = getShard(key);
|
||||
return j.getrange(key, startOffset, endOffset);
|
||||
}
|
||||
|
||||
public Long move(byte[] key, int dbIndex) {
|
||||
Jedis j = getShard(key);
|
||||
return j.move(key, dbIndex);
|
||||
}
|
||||
|
||||
public byte[] echo(byte[] arg) {
|
||||
Jedis j = getShard(arg);
|
||||
return j.echo(arg);
|
||||
}
|
||||
|
||||
public List<byte[]> brpop(byte[] arg) {
|
||||
Jedis j = getShard(arg);
|
||||
return j.brpop(arg);
|
||||
}
|
||||
|
||||
public List<byte[]> blpop(byte[] arg) {
|
||||
Jedis j = getShard(arg);
|
||||
return j.blpop(arg);
|
||||
}
|
||||
|
||||
public Long bitcount(byte[] key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.bitcount(key);
|
||||
}
|
||||
|
||||
public Long bitcount(byte[] key, long start, long end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.bitcount(key, start, end);
|
||||
}
|
||||
}
|
||||
@@ -1,546 +0,0 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import redis.clients.jedis.BinaryClient.LIST_POSITION;
|
||||
|
||||
public class BinaryTransaction extends Queable {
|
||||
protected Client client = null;
|
||||
protected boolean inTransaction = true;
|
||||
|
||||
public BinaryTransaction() {
|
||||
}
|
||||
|
||||
public BinaryTransaction(final Client client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
public List<Object> exec() {
|
||||
client.exec();
|
||||
client.getAll(1); // Discard all but the last reply
|
||||
|
||||
List<Object> unformatted = client.getObjectMultiBulkReply();
|
||||
if (unformatted == null) {
|
||||
return null;
|
||||
}
|
||||
List<Object> formatted = new ArrayList<Object>();
|
||||
for (Object o : unformatted) {
|
||||
formatted.add(generateResponse(o).get());
|
||||
}
|
||||
return formatted;
|
||||
}
|
||||
|
||||
public String discard() {
|
||||
client.discard();
|
||||
client.getAll(1); // Discard all but the last reply
|
||||
inTransaction = false;
|
||||
clean();
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public Response<Long> append(byte[] key, byte[] value) {
|
||||
client.append(key, value);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<List<String>> blpop(byte[]... args) {
|
||||
client.blpop(args);
|
||||
return getResponse(BuilderFactory.STRING_LIST);
|
||||
}
|
||||
|
||||
public Response<List<String>> brpop(byte[]... args) {
|
||||
client.brpop(args);
|
||||
return getResponse(BuilderFactory.STRING_LIST);
|
||||
}
|
||||
|
||||
public Response<Long> decr(byte[] key) {
|
||||
client.decr(key);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> decrBy(byte[] key, long integer) {
|
||||
client.decrBy(key, integer);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> del(byte[]... keys) {
|
||||
client.del(keys);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<String> echo(byte[] string) {
|
||||
client.echo(string);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Boolean> exists(byte[] key) {
|
||||
client.exists(key);
|
||||
return getResponse(BuilderFactory.BOOLEAN);
|
||||
}
|
||||
|
||||
public Response<Long> expire(byte[] key, int seconds) {
|
||||
client.expire(key, seconds);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> expireAt(byte[] key, long unixTime) {
|
||||
client.expireAt(key, unixTime);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<byte[]> get(byte[] key) {
|
||||
client.get(key);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY);
|
||||
}
|
||||
|
||||
public Response<String> getSet(byte[] key, byte[] value) {
|
||||
client.getSet(key, value);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Long> hdel(byte[] key, byte[] field) {
|
||||
client.hdel(key, field);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Boolean> hexists(byte[] key, byte[] field) {
|
||||
client.hexists(key, field);
|
||||
return getResponse(BuilderFactory.BOOLEAN);
|
||||
}
|
||||
|
||||
public Response<byte[]> hget(byte[] key, byte[] field) {
|
||||
client.hget(key, field);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY);
|
||||
}
|
||||
|
||||
public Response<Map<String, String>> hgetAll(byte[] key) {
|
||||
client.hgetAll(key);
|
||||
return getResponse(BuilderFactory.STRING_MAP);
|
||||
}
|
||||
|
||||
public Response<Long> hincrBy(byte[] key, byte[] field, long value) {
|
||||
client.hincrBy(key, field, value);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Set<byte[]>> hkeys(byte[] key) {
|
||||
client.hkeys(key);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_ZSET);
|
||||
}
|
||||
|
||||
public Response<Long> hlen(byte[] key) {
|
||||
client.hlen(key);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<List<byte[]>> hmget(byte[] key, byte[]... fields) {
|
||||
client.hmget(key, fields);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_LIST);
|
||||
}
|
||||
|
||||
public Response<byte[]> hmset(byte[] key, Map<byte[], byte[]> hash) {
|
||||
client.hmset(key, hash);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY);
|
||||
}
|
||||
|
||||
public Response<Long> hset(byte[] key, byte[] field, byte[] value) {
|
||||
client.hset(key, field, value);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> hsetnx(byte[] key, byte[] field, byte[] value) {
|
||||
client.hsetnx(key, field, value);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<List<byte[]>> hvals(byte[] key) {
|
||||
client.hvals(key);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_LIST);
|
||||
}
|
||||
|
||||
public Response<Long> incr(byte[] key) {
|
||||
client.incr(key);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> incrBy(byte[] key, long integer) {
|
||||
client.incrBy(key, integer);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Set<byte[]>> keys(byte[] pattern) {
|
||||
client.keys(pattern);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_ZSET);
|
||||
}
|
||||
|
||||
public Response<byte[]> lindex(byte[] key, long index) {
|
||||
client.lindex(key, index);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY);
|
||||
}
|
||||
|
||||
public Response<Long> linsert(byte[] key, LIST_POSITION where,
|
||||
byte[] pivot, byte[] value) {
|
||||
client.linsert(key, where, pivot, value);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> llen(byte[] key) {
|
||||
client.llen(key);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<byte[]> lpop(byte[] key) {
|
||||
client.lpop(key);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY);
|
||||
}
|
||||
|
||||
public Response<Long> lpush(byte[] key, byte[] string) {
|
||||
client.lpush(key, string);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> lpushx(byte[] key, byte[] bytes) {
|
||||
client.lpushx(key, bytes);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<List<byte[]>> lrange(byte[] key, long start, long end) {
|
||||
client.lrange(key, start, end);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_LIST);
|
||||
}
|
||||
|
||||
public Response<Long> lrem(byte[] key, long count, byte[] value) {
|
||||
client.lrem(key, count, value);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<String> lset(byte[] key, long index, byte[] value) {
|
||||
client.lset(key, index, value);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<String> ltrim(byte[] key, long start, long end) {
|
||||
client.ltrim(key, start, end);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<List<byte[]>> mget(byte[]... keys) {
|
||||
client.mget(keys);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_LIST);
|
||||
}
|
||||
|
||||
public Response<Long> move(byte[] key, int dbIndex) {
|
||||
client.move(key, dbIndex);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<String> mset(byte[]... keysvalues) {
|
||||
client.mset(keysvalues);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Long> msetnx(byte[]... keysvalues) {
|
||||
client.msetnx(keysvalues);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> persist(byte[] key) {
|
||||
client.persist(key);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<String> rename(byte[] oldkey, byte[] newkey) {
|
||||
client.rename(oldkey, newkey);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Long> renamenx(byte[] oldkey, byte[] newkey) {
|
||||
client.renamenx(oldkey, newkey);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<byte[]> rpop(byte[] key) {
|
||||
client.rpop(key);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY);
|
||||
}
|
||||
|
||||
public Response<byte[]> rpoplpush(byte[] srckey, byte[] dstkey) {
|
||||
client.rpoplpush(srckey, dstkey);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY);
|
||||
}
|
||||
|
||||
public Response<Long> rpush(byte[] key, byte[] string) {
|
||||
client.rpush(key, string);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> rpushx(byte[] key, byte[] string) {
|
||||
client.rpushx(key, string);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> sadd(byte[] key, byte[] member) {
|
||||
client.sadd(key, member);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> scard(byte[] key) {
|
||||
client.scard(key);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Set<byte[]>> sdiff(byte[]... keys) {
|
||||
client.sdiff(keys);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_ZSET);
|
||||
}
|
||||
|
||||
public Response<Long> sdiffstore(byte[] dstkey, byte[]... keys) {
|
||||
client.sdiffstore(dstkey, keys);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<byte[]> set(byte[] key, byte[] value) {
|
||||
client.set(key, value);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY);
|
||||
}
|
||||
|
||||
public Response<Boolean> setbit(String key, long offset, boolean value) {
|
||||
client.setbit(key, offset, value);
|
||||
return getResponse(BuilderFactory.BOOLEAN);
|
||||
}
|
||||
|
||||
public Response<String> setex(byte[] key, int seconds, byte[] value) {
|
||||
client.setex(key, seconds, value);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Long> setnx(byte[] key, byte[] value) {
|
||||
client.setnx(key, value);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Set<byte[]>> sinter(byte[]... keys) {
|
||||
client.sinter(keys);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_ZSET);
|
||||
}
|
||||
|
||||
public Response<Long> sinterstore(byte[] dstkey, byte[]... keys) {
|
||||
client.sinterstore(dstkey, keys);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Boolean> sismember(byte[] key, byte[] member) {
|
||||
client.sismember(key, member);
|
||||
return getResponse(BuilderFactory.BOOLEAN);
|
||||
}
|
||||
|
||||
public Response<Set<byte[]>> smembers(byte[] key) {
|
||||
client.smembers(key);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_ZSET);
|
||||
}
|
||||
|
||||
public Response<Long> smove(byte[] srckey, byte[] dstkey, byte[] member) {
|
||||
client.smove(srckey, dstkey, member);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<List<byte[]>> sort(byte[] key) {
|
||||
client.sort(key);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_LIST);
|
||||
}
|
||||
|
||||
public Response<List<byte[]>> sort(byte[] key,
|
||||
SortingParams sortingParameters) {
|
||||
client.sort(key, sortingParameters);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_LIST);
|
||||
}
|
||||
|
||||
public Response<List<byte[]>> sort(byte[] key,
|
||||
SortingParams sortingParameters, byte[] dstkey) {
|
||||
client.sort(key, sortingParameters, dstkey);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_LIST);
|
||||
}
|
||||
|
||||
public Response<List<byte[]>> sort(byte[] key, byte[] dstkey) {
|
||||
client.sort(key, dstkey);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_LIST);
|
||||
}
|
||||
|
||||
public Response<byte[]> spop(byte[] key) {
|
||||
client.spop(key);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY);
|
||||
}
|
||||
|
||||
public Response<byte[]> srandmember(byte[] key) {
|
||||
client.srandmember(key);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY);
|
||||
}
|
||||
|
||||
public Response<Long> srem(byte[] key, byte[] member) {
|
||||
client.srem(key, member);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> strlen(byte[] key) {
|
||||
client.strlen(key);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<String> substr(byte[] key, int start, int end) { // what's
|
||||
// that?
|
||||
client.substr(key, start, end);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Set<byte[]>> sunion(byte[]... keys) {
|
||||
client.sunion(keys);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_ZSET);
|
||||
}
|
||||
|
||||
public Response<Long> sunionstore(byte[] dstkey, byte[]... keys) {
|
||||
client.sunionstore(dstkey, keys);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> ttl(byte[] key) {
|
||||
client.ttl(key);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<String> type(byte[] key) {
|
||||
client.type(key);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Long> zadd(byte[] key, double score, byte[] member) {
|
||||
client.zadd(key, score, member);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> zcard(byte[] key) {
|
||||
client.zcard(key);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> zcount(byte[] key, double min, double max) {
|
||||
client.zcount(key, min, max);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Double> zincrby(byte[] key, double score, byte[] member) {
|
||||
client.zincrby(key, score, member);
|
||||
return getResponse(BuilderFactory.DOUBLE);
|
||||
}
|
||||
|
||||
public Response<Long> zinterstore(byte[] dstkey, byte[]... sets) {
|
||||
client.zinterstore(dstkey, sets);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> zinterstore(byte[] dstkey, ZParams params,
|
||||
byte[]... sets) {
|
||||
client.zinterstore(dstkey, params, sets);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Set<byte[]>> zrange(byte[] key, int start, int end) {
|
||||
client.zrange(key, start, end);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_ZSET);
|
||||
}
|
||||
|
||||
public Response<Set<byte[]>> zrangeByScore(byte[] key, double min,
|
||||
double max) {
|
||||
client.zrangeByScore(key, min, max);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_ZSET);
|
||||
}
|
||||
|
||||
public Response<Set<byte[]>> zrangeByScore(byte[] key, byte[] min,
|
||||
byte[] max) {
|
||||
client.zrangeByScore(key, min, max);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_ZSET);
|
||||
}
|
||||
|
||||
public Response<Set<byte[]>> zrangeByScore(byte[] key, double min,
|
||||
double max, int offset, int count) {
|
||||
client.zrangeByScore(key, min, max, offset, count);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_ZSET);
|
||||
}
|
||||
|
||||
public Response<Set<Tuple>> zrangeByScoreWithScores(byte[] key, double min,
|
||||
double max) {
|
||||
client.zrangeByScoreWithScores(key, min, max);
|
||||
return getResponse(BuilderFactory.TUPLE_ZSET_BINARY);
|
||||
}
|
||||
|
||||
public Response<Set<Tuple>> zrangeByScoreWithScores(byte[] key, double min,
|
||||
double max, int offset, int count) {
|
||||
client.zrangeByScoreWithScores(key, min, max, offset, count);
|
||||
return getResponse(BuilderFactory.TUPLE_ZSET_BINARY);
|
||||
}
|
||||
|
||||
public Response<Set<Tuple>> zrangeWithScores(byte[] key, int start, int end) {
|
||||
client.zrangeWithScores(key, start, end);
|
||||
return getResponse(BuilderFactory.TUPLE_ZSET_BINARY);
|
||||
}
|
||||
|
||||
public Response<Long> zrank(byte[] key, byte[] member) {
|
||||
client.zrank(key, member);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> zrem(byte[] key, byte[] member) {
|
||||
client.zrem(key, member);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> zremrangeByRank(byte[] key, int start, int end) {
|
||||
client.zremrangeByRank(key, start, end);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> zremrangeByScore(byte[] key, double start, double end) {
|
||||
client.zremrangeByScore(key, start, end);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Set<byte[]>> zrevrange(byte[] key, int start, int end) {
|
||||
client.zrevrange(key, start, end);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_ZSET);
|
||||
}
|
||||
|
||||
public Response<Set<Tuple>> zrevrangeWithScores(byte[] key, int start,
|
||||
int end) {
|
||||
client.zrevrangeWithScores(key, start, end);
|
||||
return getResponse(BuilderFactory.TUPLE_ZSET_BINARY);
|
||||
}
|
||||
|
||||
public Response<Long> zrevrank(byte[] key, byte[] member) {
|
||||
client.zrevrank(key, member);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Double> zscore(byte[] key, byte[] member) {
|
||||
client.zscore(key, member);
|
||||
return getResponse(BuilderFactory.DOUBLE);
|
||||
}
|
||||
|
||||
public Response<Long> zunionstore(byte[] dstkey, byte[]... sets) {
|
||||
client.zunionstore(dstkey, sets);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> zunionstore(byte[] dstkey, ZParams params,
|
||||
byte[]... sets) {
|
||||
client.zunionstore(dstkey, params, sets);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<byte[]> brpoplpush(byte[] source, byte[] destination,
|
||||
int timeout) {
|
||||
client.brpoplpush(source, destination, timeout);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY);
|
||||
}
|
||||
}
|
||||
8
src/main/java/redis/clients/jedis/BitOP.java
Normal file
8
src/main/java/redis/clients/jedis/BitOP.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
public enum BitOP {
|
||||
AND,
|
||||
OR,
|
||||
XOR,
|
||||
NOT;
|
||||
}
|
||||
28
src/main/java/redis/clients/jedis/BuilderFactory.java
Normal file → Executable file
28
src/main/java/redis/clients/jedis/BuilderFactory.java
Normal file → Executable file
@@ -7,7 +7,8 @@ import java.util.*;
|
||||
public class BuilderFactory {
|
||||
public static final Builder<Double> DOUBLE = new Builder<Double>() {
|
||||
public Double build(Object data) {
|
||||
return Double.valueOf(STRING.build(data));
|
||||
String asString = STRING.build(data);
|
||||
return asString == null ? null : Double.valueOf(asString);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
@@ -143,6 +144,13 @@ public class BuilderFactory {
|
||||
}
|
||||
List<byte[]> l = (List<byte[]>) data;
|
||||
final Set<byte[]> result = new LinkedHashSet<byte[]>(l);
|
||||
for (final byte[] barray : l) {
|
||||
if (barray == null) {
|
||||
result.add(null);
|
||||
} else {
|
||||
result.add(barray);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -150,6 +158,24 @@ public class BuilderFactory {
|
||||
return "ZSet<byte[]>";
|
||||
}
|
||||
};
|
||||
public static final Builder<Map<byte[], byte[]>> BYTE_ARRAY_MAP = new Builder<Map<byte[], byte[]>>() {
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<byte[], byte[]> build(Object data) {
|
||||
final List<byte[]> flatHash = (List<byte[]>) data;
|
||||
final Map<byte[], byte[]> hash = new HashMap<byte[], byte[]>();
|
||||
final Iterator<byte[]> iterator = flatHash.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
hash.put(iterator.next(), iterator.next());
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Map<byte[], byte[]>";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public static final Builder<Set<String>> STRING_ZSET = new Builder<Set<String>>() {
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -30,6 +30,8 @@ public interface Commands {
|
||||
|
||||
public void setbit(String key, long offset, boolean value);
|
||||
|
||||
public void setbit(String key, long offset, String value);
|
||||
|
||||
public void getbit(String key, long offset);
|
||||
|
||||
public void setrange(String key, long offset, String value);
|
||||
@@ -76,7 +78,7 @@ public interface Commands {
|
||||
|
||||
public void hexists(final String key, final String field);
|
||||
|
||||
public void hdel(final String key, final String field);
|
||||
public void hdel(final String key, final String... fields);
|
||||
|
||||
public void hlen(final String key);
|
||||
|
||||
@@ -86,9 +88,9 @@ public interface Commands {
|
||||
|
||||
public void hgetAll(final String key);
|
||||
|
||||
public void rpush(final String key, final String string);
|
||||
public void rpush(final String key, final String... strings);
|
||||
|
||||
public void lpush(final String key, final String string);
|
||||
public void lpush(final String key, final String... strings);
|
||||
|
||||
public void llen(final String key);
|
||||
|
||||
@@ -108,16 +110,16 @@ public interface Commands {
|
||||
|
||||
public void rpoplpush(final String srckey, final String dstkey);
|
||||
|
||||
public void sadd(final String key, final String member);
|
||||
public void sadd(final String key, final String... members);
|
||||
|
||||
public void smembers(final String key);
|
||||
|
||||
public void srem(final String key, final String member);
|
||||
public void srem(final String key, final String... member);
|
||||
|
||||
public void spop(final String key);
|
||||
|
||||
public void smove(final String srckey, final String dstkey,
|
||||
final String member);
|
||||
final String member);
|
||||
|
||||
public void scard(final String key);
|
||||
|
||||
@@ -139,24 +141,26 @@ public interface Commands {
|
||||
|
||||
public void zadd(final String key, final double score, final String member);
|
||||
|
||||
public void zrange(final String key, final int start, final int end);
|
||||
public void zadd(final String key, final Map<Double, String> scoreMembers);
|
||||
|
||||
public void zrem(final String key, final String member);
|
||||
public void zrange(final String key, final long start, final long end);
|
||||
|
||||
public void zrem(final String key, final String... members);
|
||||
|
||||
public void zincrby(final String key, final double score,
|
||||
final String member);
|
||||
final String member);
|
||||
|
||||
public void zrank(final String key, final String member);
|
||||
|
||||
public void zrevrank(final String key, final String member);
|
||||
|
||||
public void zrevrange(final String key, final int start, final int end);
|
||||
public void zrevrange(final String key, final long start, final long end);
|
||||
|
||||
public void zrangeWithScores(final String key, final int start,
|
||||
final int end);
|
||||
public void zrangeWithScores(final String key, final long start,
|
||||
final long end);
|
||||
|
||||
public void zrevrangeWithScores(final String key, final int start,
|
||||
final int end);
|
||||
public void zrevrangeWithScores(final String key, final long start,
|
||||
final long end);
|
||||
|
||||
public void zcard(final String key);
|
||||
|
||||
@@ -171,74 +175,92 @@ public interface Commands {
|
||||
public void blpop(final String[] args);
|
||||
|
||||
public void sort(final String key, final SortingParams sortingParameters,
|
||||
final String dstkey);
|
||||
final String dstkey);
|
||||
|
||||
public void sort(final String key, final String dstkey);
|
||||
|
||||
public void brpop(final String[] args);
|
||||
|
||||
public void brpoplpush(final String source, final String destination,
|
||||
final int timeout);
|
||||
final int timeout);
|
||||
|
||||
public void zcount(final String key, final double min, final double max);
|
||||
|
||||
public void zcount(final String key, final String min, final String max);
|
||||
|
||||
public void zrangeByScore(final String key, final double min,
|
||||
final double max);
|
||||
final double max);
|
||||
|
||||
public void zrangeByScore(final String key, final String min,
|
||||
final String max);
|
||||
final String max);
|
||||
|
||||
public void zrangeByScore(final String key, final double min,
|
||||
final double max, final int offset, int count);
|
||||
final double max, final int offset, int count);
|
||||
|
||||
public void zrangeByScoreWithScores(final String key, final double min,
|
||||
final double max);
|
||||
final double max);
|
||||
|
||||
public void zrangeByScoreWithScores(final String key, final double min,
|
||||
final double max, final int offset, final int count);
|
||||
final double max, final int offset, final int count);
|
||||
|
||||
public void zrangeByScoreWithScores(final String key, final String min,
|
||||
final String max);
|
||||
|
||||
public void zrangeByScoreWithScores(final String key, final String min,
|
||||
final String max, final int offset, final int count);
|
||||
|
||||
public void zrevrangeByScore(final String key, final double max,
|
||||
final double min);
|
||||
final double min);
|
||||
|
||||
public void zrevrangeByScore(final String key, final String max,
|
||||
final String min);
|
||||
final String min);
|
||||
|
||||
public void zrevrangeByScore(final String key, final double max,
|
||||
final double min, final int offset, int count);
|
||||
final double min, final int offset, int count);
|
||||
|
||||
public void zrevrangeByScoreWithScores(final String key, final double max,
|
||||
final double min);
|
||||
final double min);
|
||||
|
||||
public void zrevrangeByScoreWithScores(final String key, final double max,
|
||||
final double min, final int offset, final int count);
|
||||
final double min, final int offset, final int count);
|
||||
|
||||
public void zremrangeByRank(final String key, final int start, final int end);
|
||||
public void zrevrangeByScoreWithScores(final String key, final String max,
|
||||
final String min);
|
||||
|
||||
public void zrevrangeByScoreWithScores(final String key, final String max,
|
||||
final String min, final int offset, final int count);
|
||||
|
||||
public void zremrangeByRank(final String key, final long start,
|
||||
final long end);
|
||||
|
||||
public void zremrangeByScore(final String key, final double start,
|
||||
final double end);
|
||||
final double end);
|
||||
|
||||
public void zremrangeByScore(final String key, final String start,
|
||||
final String end);
|
||||
|
||||
public void zunionstore(final String dstkey, final String... sets);
|
||||
|
||||
public void zunionstore(final String dstkey, final ZParams params,
|
||||
final String... sets);
|
||||
final String... sets);
|
||||
|
||||
public void zinterstore(final String dstkey, final String... sets);
|
||||
|
||||
public void zinterstore(final String dstkey, final ZParams params,
|
||||
final String... sets);
|
||||
final String... sets);
|
||||
|
||||
public void strlen(final String key);
|
||||
|
||||
public void lpushx(final String key, final String string);
|
||||
public void lpushx(final String key, final String... string);
|
||||
|
||||
public void persist(final String key);
|
||||
|
||||
public void rpushx(final String key, final String string);
|
||||
public void rpushx(final String key, final String... string);
|
||||
|
||||
public void echo(final String string);
|
||||
|
||||
public void linsert(final String key, final LIST_POSITION where,
|
||||
final String pivot, final String value);
|
||||
final String pivot, final String value);
|
||||
|
||||
public void bgrewriteaof();
|
||||
|
||||
@@ -259,4 +281,16 @@ public interface Commands {
|
||||
public void exec();
|
||||
|
||||
public void discard();
|
||||
}
|
||||
|
||||
public void objectRefcount(String key);
|
||||
|
||||
public void objectIdletime(String key);
|
||||
|
||||
public void objectEncoding(String key);
|
||||
|
||||
public void bitcount(final String key);
|
||||
|
||||
public void bitcount(final String key, long start, long end);
|
||||
|
||||
public void bitop(BitOP op, final String destKey, String... srcKeys);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.util.List;
|
||||
|
||||
import redis.clients.jedis.Protocol.Command;
|
||||
import redis.clients.jedis.exceptions.JedisConnectionException;
|
||||
import redis.clients.jedis.exceptions.JedisDataException;
|
||||
import redis.clients.jedis.exceptions.JedisException;
|
||||
import redis.clients.util.RedisInputStream;
|
||||
import redis.clients.util.RedisOutputStream;
|
||||
@@ -18,7 +19,6 @@ public class Connection {
|
||||
private String host;
|
||||
private int port = Protocol.DEFAULT_PORT;
|
||||
private Socket socket;
|
||||
private Protocol protocol = new Protocol();
|
||||
private RedisOutputStream outputStream;
|
||||
private RedisInputStream inputStream;
|
||||
private int pipelinedCommands = 0;
|
||||
@@ -38,6 +38,10 @@ public class Connection {
|
||||
|
||||
public void setTimeoutInfinite() {
|
||||
try {
|
||||
if(!isConnected()) {
|
||||
connect();
|
||||
}
|
||||
socket.setKeepAlive(true);
|
||||
socket.setSoTimeout(0);
|
||||
} catch (SocketException ex) {
|
||||
throw new JedisException(ex);
|
||||
@@ -47,6 +51,7 @@ public class Connection {
|
||||
public void rollbackTimeout() {
|
||||
try {
|
||||
socket.setSoTimeout(timeout);
|
||||
socket.setKeepAlive(false);
|
||||
} catch (SocketException ex) {
|
||||
throw new JedisException(ex);
|
||||
}
|
||||
@@ -75,14 +80,14 @@ public class Connection {
|
||||
|
||||
protected Connection sendCommand(final Command cmd, final byte[]... args) {
|
||||
connect();
|
||||
protocol.sendCommand(outputStream, cmd, args);
|
||||
Protocol.sendCommand(outputStream, cmd, args);
|
||||
pipelinedCommands++;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
protected Connection sendCommand(final Command cmd) {
|
||||
connect();
|
||||
protocol.sendCommand(outputStream, cmd, new byte[0][]);
|
||||
Protocol.sendCommand(outputStream, cmd, new byte[0][]);
|
||||
pipelinedCommands++;
|
||||
return this;
|
||||
}
|
||||
@@ -110,12 +115,20 @@ public class Connection {
|
||||
}
|
||||
|
||||
public Connection() {
|
||||
|
||||
}
|
||||
|
||||
public void connect() {
|
||||
if (!isConnected()) {
|
||||
try {
|
||||
socket = new Socket();
|
||||
//->@wjw_add
|
||||
socket.setReuseAddress(true);
|
||||
socket.setKeepAlive(true); //Will monitor the TCP connection is valid
|
||||
socket.setTcpNoDelay(true); //Socket buffer Whetherclosed, to ensure timely delivery of data
|
||||
socket.setSoLinger(true,0); //Control calls close () method, the underlying socket is closed immediately
|
||||
//<-@wjw_add
|
||||
|
||||
socket.connect(new InetSocketAddress(host, port), timeout);
|
||||
socket.setSoTimeout(timeout);
|
||||
outputStream = new RedisOutputStream(socket.getOutputStream());
|
||||
@@ -149,7 +162,7 @@ public class Connection {
|
||||
protected String getStatusCodeReply() {
|
||||
flush();
|
||||
pipelinedCommands--;
|
||||
final byte[] resp = (byte[]) protocol.read(inputStream);
|
||||
final byte[] resp = (byte[]) Protocol.read(inputStream);
|
||||
if (null == resp) {
|
||||
return null;
|
||||
} else {
|
||||
@@ -169,13 +182,13 @@ public class Connection {
|
||||
public byte[] getBinaryBulkReply() {
|
||||
flush();
|
||||
pipelinedCommands--;
|
||||
return (byte[]) protocol.read(inputStream);
|
||||
return (byte[]) Protocol.read(inputStream);
|
||||
}
|
||||
|
||||
public Long getIntegerReply() {
|
||||
flush();
|
||||
pipelinedCommands--;
|
||||
return (Long) protocol.read(inputStream);
|
||||
return (Long) Protocol.read(inputStream);
|
||||
}
|
||||
|
||||
public List<String> getMultiBulkReply() {
|
||||
@@ -186,14 +199,21 @@ public class Connection {
|
||||
public List<byte[]> getBinaryMultiBulkReply() {
|
||||
flush();
|
||||
pipelinedCommands--;
|
||||
return (List<byte[]>) protocol.read(inputStream);
|
||||
return (List<byte[]>) Protocol.read(inputStream);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> getObjectMultiBulkReply() {
|
||||
flush();
|
||||
pipelinedCommands--;
|
||||
return (List<Object>) protocol.read(inputStream);
|
||||
return (List<Object>) Protocol.read(inputStream);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Long> getIntegerMultiBulkReply() {
|
||||
flush();
|
||||
pipelinedCommands--;
|
||||
return (List<Long>) Protocol.read(inputStream);
|
||||
}
|
||||
|
||||
public List<Object> getAll() {
|
||||
@@ -204,7 +224,11 @@ public class Connection {
|
||||
List<Object> all = new ArrayList<Object>();
|
||||
flush();
|
||||
while (pipelinedCommands > except) {
|
||||
all.add(protocol.read(inputStream));
|
||||
try{
|
||||
all.add(Protocol.read(inputStream));
|
||||
}catch(JedisDataException e){
|
||||
all.add(e);
|
||||
}
|
||||
pipelinedCommands--;
|
||||
}
|
||||
return all;
|
||||
@@ -213,6 +237,6 @@ public class Connection {
|
||||
public Object getOne() {
|
||||
flush();
|
||||
pipelinedCommands--;
|
||||
return protocol.read(inputStream);
|
||||
return Protocol.read(inputStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -14,6 +14,8 @@ public interface JedisCommands {
|
||||
|
||||
Boolean exists(String key);
|
||||
|
||||
Long persist(String key);
|
||||
|
||||
String type(String key);
|
||||
|
||||
Long expire(String key, int seconds);
|
||||
@@ -22,11 +24,13 @@ public interface JedisCommands {
|
||||
|
||||
Long ttl(String key);
|
||||
|
||||
boolean setbit(String key, long offset, boolean value);
|
||||
Boolean setbit(String key, long offset, boolean value);
|
||||
|
||||
boolean getbit(String key, long offset);
|
||||
Boolean setbit(String key, long offset, String value);
|
||||
|
||||
long setrange(String key, long offset, String value);
|
||||
Boolean getbit(String key, long offset);
|
||||
|
||||
Long setrange(String key, long offset, String value);
|
||||
|
||||
String getrange(String key, long startOffset, long endOffset);
|
||||
|
||||
@@ -62,7 +66,7 @@ public interface JedisCommands {
|
||||
|
||||
Boolean hexists(String key, String field);
|
||||
|
||||
Long hdel(String key, String field);
|
||||
Long hdel(String key, String... field);
|
||||
|
||||
Long hlen(String key);
|
||||
|
||||
@@ -72,9 +76,9 @@ public interface JedisCommands {
|
||||
|
||||
Map<String, String> hgetAll(String key);
|
||||
|
||||
Long rpush(String key, String string);
|
||||
Long rpush(String key, String... string);
|
||||
|
||||
Long lpush(String key, String string);
|
||||
Long lpush(String key, String... string);
|
||||
|
||||
Long llen(String key);
|
||||
|
||||
@@ -92,11 +96,11 @@ public interface JedisCommands {
|
||||
|
||||
String rpop(String key);
|
||||
|
||||
Long sadd(String key, String member);
|
||||
Long sadd(String key, String... member);
|
||||
|
||||
Set<String> smembers(String key);
|
||||
|
||||
Long srem(String key, String member);
|
||||
Long srem(String key, String... member);
|
||||
|
||||
String spop(String key);
|
||||
|
||||
@@ -106,11 +110,15 @@ public interface JedisCommands {
|
||||
|
||||
String srandmember(String key);
|
||||
|
||||
Long strlen(String key);
|
||||
|
||||
Long zadd(String key, double score, String member);
|
||||
|
||||
Long zadd(String key, Map<Double, String> scoreMembers);
|
||||
|
||||
Set<String> zrange(String key, int start, int end);
|
||||
Set<String> zrange(String key, long start, long end);
|
||||
|
||||
Long zrem(String key, String member);
|
||||
Long zrem(String key, String... member);
|
||||
|
||||
Double zincrby(String key, double score, String member);
|
||||
|
||||
@@ -118,11 +126,11 @@ public interface JedisCommands {
|
||||
|
||||
Long zrevrank(String key, String member);
|
||||
|
||||
Set<String> zrevrange(String key, int start, int end);
|
||||
Set<String> zrevrange(String key, long start, long end);
|
||||
|
||||
Set<Tuple> zrangeWithScores(String key, int start, int end);
|
||||
Set<Tuple> zrangeWithScores(String key, long start, long end);
|
||||
|
||||
Set<Tuple> zrevrangeWithScores(String key, int start, int end);
|
||||
Set<Tuple> zrevrangeWithScores(String key, long start, long end);
|
||||
|
||||
Long zcard(String key);
|
||||
|
||||
@@ -134,13 +142,22 @@ public interface JedisCommands {
|
||||
|
||||
Long zcount(String key, double min, double max);
|
||||
|
||||
Long zcount(String key, String min, String max);
|
||||
|
||||
Set<String> zrangeByScore(String key, double min, double max);
|
||||
|
||||
Set<String> zrangeByScore(String key, String min, String 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, String max, String min);
|
||||
|
||||
Set<String> zrangeByScore(String key, String min, String max, int offset,
|
||||
int count);
|
||||
|
||||
Set<String> zrevrangeByScore(String key, double max, double min,
|
||||
int offset, int count);
|
||||
|
||||
@@ -150,14 +167,47 @@ public interface JedisCommands {
|
||||
|
||||
Set<Tuple> zrangeByScoreWithScores(String key, double min, double max,
|
||||
int offset, int count);
|
||||
|
||||
Set<String> zrevrangeByScore(String key, String max, String min,
|
||||
int offset, int count);
|
||||
|
||||
Set<Tuple> zrangeByScoreWithScores(String key, String min, String max);
|
||||
|
||||
Set<Tuple> zrevrangeByScoreWithScores(String key, String max, String min);
|
||||
|
||||
Set<Tuple> zrangeByScoreWithScores(String key, String min, String max,
|
||||
int offset, int count);
|
||||
|
||||
Set<Tuple> zrevrangeByScoreWithScores(String key, double max, double min,
|
||||
int offset, int count);
|
||||
|
||||
Set<Tuple> zrevrangeByScoreWithScores(String key, String max, String min,
|
||||
int offset, int count);
|
||||
|
||||
Long zremrangeByRank(String key, int start, int end);
|
||||
Long zremrangeByRank(String key, long start, long end);
|
||||
|
||||
Long zremrangeByScore(String key, double start, double end);
|
||||
|
||||
Long zremrangeByScore(String key, String start, String end);
|
||||
|
||||
Long linsert(String key, Client.LIST_POSITION where, String pivot,
|
||||
String value);
|
||||
|
||||
Long lpushx(String key, String... string);
|
||||
|
||||
Long rpushx(String key, String... string);
|
||||
|
||||
List<String> blpop(String arg);
|
||||
|
||||
List<String> brpop(String arg);
|
||||
|
||||
Long del(String key);
|
||||
|
||||
String echo(String string);
|
||||
|
||||
Long move(String key, int dbIndex);
|
||||
|
||||
Long bitcount(final String key);
|
||||
|
||||
Long bitcount(final String key, long start, long end);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.apache.commons.pool.BasePoolableObjectFactory;
|
||||
import org.apache.commons.pool.impl.GenericObjectPool;
|
||||
import org.apache.commons.pool.impl.GenericObjectPool.Config;
|
||||
@@ -8,32 +10,66 @@ import redis.clients.util.Pool;
|
||||
|
||||
public class JedisPool extends Pool<Jedis> {
|
||||
|
||||
public JedisPool(final GenericObjectPool.Config poolConfig,
|
||||
final String host) {
|
||||
this(poolConfig, host, Protocol.DEFAULT_PORT, Protocol.DEFAULT_TIMEOUT,
|
||||
null);
|
||||
public JedisPool(final Config poolConfig, final String host) {
|
||||
this(poolConfig, host, Protocol.DEFAULT_PORT, Protocol.DEFAULT_TIMEOUT, null, Protocol.DEFAULT_DATABASE);
|
||||
}
|
||||
|
||||
public JedisPool(String host, int port) {
|
||||
super(new Config(), new JedisFactory(host, port,
|
||||
Protocol.DEFAULT_TIMEOUT, null));
|
||||
this(new Config(), host, port, Protocol.DEFAULT_TIMEOUT, null, Protocol.DEFAULT_DATABASE);
|
||||
}
|
||||
|
||||
public JedisPool(final String host) {
|
||||
URI uri = URI.create(host);
|
||||
if (uri.getScheme() != null && uri.getScheme().equals("redis")) {
|
||||
String h = uri.getHost();
|
||||
int port = uri.getPort();
|
||||
String password = uri.getUserInfo().split(":", 2)[1];
|
||||
int database = Integer.parseInt(uri.getPath().split("/", 2)[1]);
|
||||
this.internalPool = new GenericObjectPool(new JedisFactory(h, port,
|
||||
Protocol.DEFAULT_TIMEOUT, password, database), new Config());
|
||||
} else {
|
||||
this.internalPool = new GenericObjectPool(new JedisFactory(host,
|
||||
Protocol.DEFAULT_PORT, Protocol.DEFAULT_TIMEOUT, null,
|
||||
Protocol.DEFAULT_DATABASE), new Config());
|
||||
}
|
||||
}
|
||||
|
||||
public JedisPool(final URI uri) {
|
||||
String h = uri.getHost();
|
||||
int port = uri.getPort();
|
||||
String password = uri.getUserInfo().split(":", 2)[1];
|
||||
int database = Integer.parseInt(uri.getPath().split("/", 2)[1]);
|
||||
this.internalPool = new GenericObjectPool(new JedisFactory(h, port,
|
||||
Protocol.DEFAULT_TIMEOUT, password, database), new Config());
|
||||
}
|
||||
|
||||
public JedisPool(final Config poolConfig, final String host, int port,
|
||||
int timeout, final String password) {
|
||||
super(poolConfig, new JedisFactory(host, port, timeout, password));
|
||||
this(poolConfig, host, port, timeout, password, Protocol.DEFAULT_DATABASE);
|
||||
}
|
||||
|
||||
public JedisPool(final GenericObjectPool.Config poolConfig,
|
||||
final String host, final int port) {
|
||||
this(poolConfig, host, port, Protocol.DEFAULT_TIMEOUT, null);
|
||||
public JedisPool(final Config poolConfig, final String host, final int port) {
|
||||
this(poolConfig, host, port, Protocol.DEFAULT_TIMEOUT, null, Protocol.DEFAULT_DATABASE);
|
||||
}
|
||||
|
||||
public JedisPool(final GenericObjectPool.Config poolConfig,
|
||||
final String host, final int port, final int timeout) {
|
||||
this(poolConfig, host, port, timeout, null);
|
||||
public JedisPool(final Config poolConfig, final String host, final int port, final int timeout) {
|
||||
this(poolConfig, host, port, timeout, null, Protocol.DEFAULT_DATABASE);
|
||||
}
|
||||
|
||||
public JedisPool(final Config poolConfig, final String host, int port, int timeout, final String password,
|
||||
final int database) {
|
||||
super(poolConfig, new JedisFactory(host, port, timeout, password, database));
|
||||
}
|
||||
|
||||
|
||||
public void returnBrokenResource(final BinaryJedis resource) {
|
||||
returnBrokenResourceObject(resource);
|
||||
}
|
||||
|
||||
public void returnResource(final BinaryJedis resource) {
|
||||
returnResourceObject(resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* PoolableObjectFactory custom impl.
|
||||
*/
|
||||
@@ -42,14 +78,16 @@ public class JedisPool extends Pool<Jedis> {
|
||||
private final int port;
|
||||
private final int timeout;
|
||||
private final String password;
|
||||
private final int database;
|
||||
|
||||
public JedisFactory(final String host, final int port,
|
||||
final int timeout, final String password) {
|
||||
final int timeout, final String password, final int database) {
|
||||
super();
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.timeout = timeout;
|
||||
this.password = password;
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
public Object makeObject() throws Exception {
|
||||
@@ -59,8 +97,22 @@ public class JedisPool extends Pool<Jedis> {
|
||||
if (null != this.password) {
|
||||
jedis.auth(this.password);
|
||||
}
|
||||
if( database != 0 ) {
|
||||
jedis.select(database);
|
||||
}
|
||||
|
||||
return jedis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activateObject(Object obj) throws Exception {
|
||||
if (obj instanceof Jedis) {
|
||||
final Jedis jedis = (Jedis)obj;
|
||||
if (jedis.getDB() != database) {
|
||||
jedis.select(database);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void destroyObject(final Object obj) throws Exception {
|
||||
if (obj instanceof Jedis) {
|
||||
@@ -91,6 +143,5 @@ public class JedisPool extends Pool<Jedis> {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import redis.clients.util.ShardInfo;
|
||||
import redis.clients.util.Sharded;
|
||||
|
||||
public class JedisShardInfo extends ShardInfo<Jedis> {
|
||||
public String toString() {
|
||||
return host + ":" + port + "*" + getWeight();
|
||||
return host + ":" + port + "*" + getWeight();
|
||||
}
|
||||
|
||||
private int timeout;
|
||||
@@ -15,67 +17,83 @@ public class JedisShardInfo extends ShardInfo<Jedis> {
|
||||
private String name = null;
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
return host;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
return port;
|
||||
}
|
||||
|
||||
public JedisShardInfo(String host) {
|
||||
this(host, Protocol.DEFAULT_PORT);
|
||||
super(Sharded.DEFAULT_WEIGHT);
|
||||
URI uri = URI.create(host);
|
||||
if (uri.getScheme() != null && uri.getScheme().equals("redis")) {
|
||||
this.host = uri.getHost();
|
||||
this.port = uri.getPort();
|
||||
this.password = uri.getUserInfo().split(":", 2)[1];
|
||||
} else {
|
||||
this.host = host;
|
||||
this.port = Protocol.DEFAULT_PORT;
|
||||
}
|
||||
}
|
||||
|
||||
public JedisShardInfo(String host, String name) {
|
||||
this(host, Protocol.DEFAULT_PORT, name);
|
||||
this(host, Protocol.DEFAULT_PORT, name);
|
||||
}
|
||||
|
||||
public JedisShardInfo(String host, int port) {
|
||||
this(host, port, 2000);
|
||||
this(host, port, 2000);
|
||||
}
|
||||
|
||||
public JedisShardInfo(String host, int port, String name) {
|
||||
this(host, port, 2000, name);
|
||||
this(host, port, 2000, name);
|
||||
}
|
||||
|
||||
public JedisShardInfo(String host, int port, int timeout) {
|
||||
this(host, port, timeout, Sharded.DEFAULT_WEIGHT);
|
||||
this(host, port, timeout, Sharded.DEFAULT_WEIGHT);
|
||||
}
|
||||
|
||||
public JedisShardInfo(String host, int port, int timeout, String name) {
|
||||
this(host, port, timeout, Sharded.DEFAULT_WEIGHT);
|
||||
this.name = name;
|
||||
this(host, port, timeout, Sharded.DEFAULT_WEIGHT);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public JedisShardInfo(String host, int port, int timeout, int weight) {
|
||||
super(weight);
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.timeout = timeout;
|
||||
super(weight);
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
public JedisShardInfo(URI uri) {
|
||||
super(Sharded.DEFAULT_WEIGHT);
|
||||
this.host = uri.getHost();
|
||||
this.port = uri.getPort();
|
||||
this.password = uri.getUserInfo().split(":", 2)[1];
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String auth) {
|
||||
this.password = auth;
|
||||
this.password = auth;
|
||||
}
|
||||
|
||||
public int getTimeout() {
|
||||
return timeout;
|
||||
return timeout;
|
||||
}
|
||||
|
||||
public void setTimeout(int timeout) {
|
||||
this.timeout = timeout;
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Jedis createResource() {
|
||||
return new Jedis(this);
|
||||
return new Jedis(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface MultiKeyBinaryCommands {
|
||||
Long del(byte[]... keys);
|
||||
|
||||
List<byte[]> blpop(int timeout, byte[]... keys);
|
||||
|
||||
List<byte[]> brpop(int timeout, byte[]... keys);
|
||||
|
||||
List<byte[]> blpop(byte[]... args);
|
||||
|
||||
List<byte[]> brpop(byte[]... args);
|
||||
|
||||
Set<byte[]> keys(byte[] pattern);
|
||||
|
||||
List<byte[]> mget(byte[]... keys);
|
||||
|
||||
String mset(byte[]... keysvalues);
|
||||
|
||||
Long msetnx(byte[]... keysvalues);
|
||||
|
||||
String rename(byte[] oldkey, byte[] newkey);
|
||||
|
||||
Long renamenx(byte[] oldkey, byte[] newkey);
|
||||
|
||||
byte[] rpoplpush(byte[] srckey, byte[] dstkey);
|
||||
|
||||
Set<byte[]> sdiff(byte[]... keys);
|
||||
|
||||
Long sdiffstore(byte[] dstkey, byte[]... keys);
|
||||
|
||||
Set<byte[]> sinter(byte[]... keys);
|
||||
|
||||
Long sinterstore(byte[] dstkey, byte[]... keys);
|
||||
|
||||
Long smove(byte[] srckey, byte[] dstkey, byte[] member);
|
||||
|
||||
Long sort(byte[] key, SortingParams sortingParameters, byte[] dstkey);
|
||||
|
||||
Long sort(byte[] key, byte[] dstkey);
|
||||
|
||||
Set<byte[]> sunion(byte[]... keys);
|
||||
|
||||
Long sunionstore(byte[] dstkey, byte[]... keys);
|
||||
|
||||
String watch(byte[]... keys);
|
||||
|
||||
String unwatch();
|
||||
|
||||
Long zinterstore(byte[] dstkey, byte[]... sets);
|
||||
|
||||
Long zinterstore(byte[] dstkey, ZParams params, byte[]... sets);
|
||||
|
||||
Long zunionstore(byte[] dstkey, byte[]... sets);
|
||||
|
||||
Long zunionstore(byte[] dstkey, ZParams params, byte[]... sets);
|
||||
|
||||
byte[] brpoplpush(byte[] source, byte[] destination, int timeout);
|
||||
|
||||
Long publish(byte[] channel, byte[] message);
|
||||
|
||||
void subscribe(BinaryJedisPubSub jedisPubSub, byte[]... channels);
|
||||
|
||||
void psubscribe(BinaryJedisPubSub jedisPubSub, byte[]... patterns);
|
||||
|
||||
byte[] randomBinaryKey();
|
||||
|
||||
Long bitop(BitOP op, final byte[] destKey, byte[]... srcKeys);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Multikey related commands (these are split out because they are non-shardable)
|
||||
*/
|
||||
public interface MultiKeyBinaryRedisPipeline {
|
||||
|
||||
Response<Long> del(byte[]... keys);
|
||||
|
||||
Response<List<byte[]>> blpop(byte[]... args);
|
||||
|
||||
Response<List<byte[]>> brpop(byte[]... args);
|
||||
|
||||
Response<Set<byte[]>> keys(byte[] pattern);
|
||||
|
||||
Response<List<byte[]>> mget(byte[]... keys);
|
||||
|
||||
Response<String> mset(byte[]... keysvalues);
|
||||
|
||||
Response<Long> msetnx(byte[]... keysvalues);
|
||||
|
||||
Response<String> rename(byte[] oldkey, byte[] newkey);
|
||||
|
||||
Response<Long> renamenx(byte[] oldkey, byte[] newkey);
|
||||
|
||||
Response<byte[]> rpoplpush(byte[] srckey, byte[] dstkey);
|
||||
|
||||
Response<Set<byte[]>> sdiff(byte[]... keys);
|
||||
|
||||
Response<Long> sdiffstore(byte[] dstkey, byte[]... keys);
|
||||
|
||||
Response<Set<byte[]>> sinter(byte[]... keys);
|
||||
|
||||
Response<Long> sinterstore(byte[] dstkey, byte[]... keys);
|
||||
|
||||
Response<Long> smove(byte[] srckey, byte[] dstkey, byte[] member);
|
||||
|
||||
Response<Long> sort(byte[] key, SortingParams sortingParameters, byte[] dstkey);
|
||||
|
||||
Response<Long> sort(byte[] key, byte[] dstkey);
|
||||
|
||||
Response<Set<byte[]>> sunion(byte[]... keys);
|
||||
|
||||
Response<Long> sunionstore(byte[] dstkey, byte[]... keys);
|
||||
|
||||
Response<String> watch(byte[]... keys);
|
||||
|
||||
Response<Long> zinterstore(byte[] dstkey, byte[]... sets);
|
||||
|
||||
Response<Long> zinterstore(byte[] dstkey, ZParams params, byte[]... sets);
|
||||
|
||||
Response<Long> zunionstore(byte[] dstkey, byte[]... sets);
|
||||
|
||||
Response<Long> zunionstore(byte[] dstkey, ZParams params, byte[]... sets);
|
||||
|
||||
Response<byte[]> brpoplpush(byte[] source, byte[] destination, int timeout);
|
||||
|
||||
Response<Long> publish(byte[] channel, byte[] message);
|
||||
|
||||
Response<byte[]> randomKeyBinary();
|
||||
|
||||
Response<Long> bitop(BitOP op, final byte[] destKey, byte[]... srcKeys);
|
||||
}
|
||||
73
src/main/java/redis/clients/jedis/MultiKeyCommands.java
Normal file
73
src/main/java/redis/clients/jedis/MultiKeyCommands.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface MultiKeyCommands {
|
||||
Long del(String... keys);
|
||||
|
||||
List<String> blpop(int timeout, String... keys);
|
||||
|
||||
List<String> brpop(int timeout, String... keys);
|
||||
|
||||
List<String> blpop(String... args);
|
||||
|
||||
List<String> brpop(String... args);
|
||||
|
||||
Set<String> keys(String pattern);
|
||||
|
||||
List<String> mget(String... keys);
|
||||
|
||||
String mset(String... keysvalues);
|
||||
|
||||
Long msetnx(String... keysvalues);
|
||||
|
||||
String rename(String oldkey, String newkey);
|
||||
|
||||
Long renamenx(String oldkey, String newkey);
|
||||
|
||||
String rpoplpush(String srckey, String dstkey);
|
||||
|
||||
Set<String> sdiff(String... keys);
|
||||
|
||||
Long sdiffstore(String dstkey, String... keys);
|
||||
|
||||
Set<String> sinter(String... keys);
|
||||
|
||||
Long sinterstore(String dstkey, String... keys);
|
||||
|
||||
Long smove(String srckey, String dstkey, String member);
|
||||
|
||||
Long sort(String key, SortingParams sortingParameters, String dstkey);
|
||||
|
||||
Long sort(String key, String dstkey);
|
||||
|
||||
Set<String> sunion(String... keys);
|
||||
|
||||
Long sunionstore(String dstkey, String... keys);
|
||||
|
||||
String watch(String... keys);
|
||||
|
||||
String unwatch();
|
||||
|
||||
Long zinterstore(String dstkey, String... sets);
|
||||
|
||||
Long zinterstore(String dstkey, ZParams params, String... sets);
|
||||
|
||||
Long zunionstore(String dstkey, String... sets);
|
||||
|
||||
Long zunionstore(String dstkey, ZParams params, String... sets);
|
||||
|
||||
String brpoplpush(String source, String destination, int timeout);
|
||||
|
||||
Long publish(String channel, String message);
|
||||
|
||||
void subscribe(JedisPubSub jedisPubSub, String... channels);
|
||||
|
||||
void psubscribe(JedisPubSub jedisPubSub, String... patterns);
|
||||
|
||||
String randomKey();
|
||||
|
||||
Long bitop(BitOP op, final String destKey, String... srcKeys);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* Multikey related commands (these are split out because they are non-shardable)
|
||||
*/
|
||||
public interface MultiKeyCommandsPipeline {
|
||||
Response<Long> del(String... keys);
|
||||
|
||||
Response<List<String>> blpop(String... args);
|
||||
|
||||
Response<List<String>> brpop(String... args);
|
||||
|
||||
Response<Set<String>> keys(String pattern);
|
||||
|
||||
Response<List<String>> mget(String... keys);
|
||||
|
||||
Response<String> mset(String... keysvalues);
|
||||
|
||||
Response<Long> msetnx(String... keysvalues);
|
||||
|
||||
Response<String> rename(String oldkey, String newkey);
|
||||
|
||||
Response<Long> renamenx(String oldkey, String newkey);
|
||||
|
||||
Response<String> rpoplpush(String srckey, String dstkey);
|
||||
|
||||
Response<Set<String>> sdiff(String... keys);
|
||||
|
||||
Response<Long> sdiffstore(String dstkey, String... keys);
|
||||
|
||||
Response<Set<String>> sinter(String... keys);
|
||||
|
||||
Response<Long> sinterstore(String dstkey, String... keys);
|
||||
|
||||
Response<Long> smove(String srckey, String dstkey, String member);
|
||||
|
||||
Response<Long> sort(String key, SortingParams sortingParameters, String dstkey);
|
||||
|
||||
Response<Long> sort(String key, String dstkey);
|
||||
|
||||
Response<Set<String>> sunion(String... keys);
|
||||
|
||||
Response<Long> sunionstore(String dstkey, String... keys);
|
||||
|
||||
Response<String> watch(String... keys);
|
||||
|
||||
Response<Long> zinterstore(String dstkey, String... sets);
|
||||
|
||||
Response<Long> zinterstore(String dstkey, ZParams params, String... sets);
|
||||
|
||||
Response<Long> zunionstore(String dstkey, String... sets);
|
||||
|
||||
Response<Long> zunionstore(String dstkey, ZParams params, String... sets);
|
||||
|
||||
Response<String> brpoplpush(String source, String destination, int timeout);
|
||||
|
||||
Response<Long> publish(String channel, String message);
|
||||
|
||||
Response<String> randomKey();
|
||||
|
||||
Response<Long> bitop(BitOP op, final String destKey, String... srcKeys);
|
||||
}
|
||||
401
src/main/java/redis/clients/jedis/MultiKeyPipelineBase.java
Normal file
401
src/main/java/redis/clients/jedis/MultiKeyPipelineBase.java
Normal file
@@ -0,0 +1,401 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
abstract class MultiKeyPipelineBase extends PipelineBase implements
|
||||
BasicRedisPipeline,
|
||||
MultiKeyBinaryRedisPipeline,
|
||||
MultiKeyCommandsPipeline {
|
||||
|
||||
protected Client client = null;
|
||||
|
||||
public Response<List<String>> brpop(String... args) {
|
||||
client.brpop(args);
|
||||
return getResponse(BuilderFactory.STRING_LIST);
|
||||
}
|
||||
|
||||
public Response<List<String>> brpop(int timeout, String... keys) {
|
||||
client.brpop(timeout, keys);
|
||||
return getResponse(BuilderFactory.STRING_LIST);
|
||||
}
|
||||
|
||||
public Response<List<String>> blpop(String... args) {
|
||||
client.blpop(args);
|
||||
return getResponse(BuilderFactory.STRING_LIST);
|
||||
}
|
||||
|
||||
public Response<List<String>> blpop(int timeout, String... keys) {
|
||||
client.blpop(timeout, keys);
|
||||
return getResponse(BuilderFactory.STRING_LIST);
|
||||
}
|
||||
|
||||
public Response<Map<String, String>> blpopMap(int timeout, String... keys) {
|
||||
client.blpop(timeout, keys);
|
||||
return getResponse(BuilderFactory.STRING_MAP);
|
||||
}
|
||||
|
||||
public Response<List<byte[]>> brpop(byte[]... args) {
|
||||
client.brpop(args);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_LIST);
|
||||
}
|
||||
|
||||
public Response<List<String>> brpop(int timeout, byte[]... keys) {
|
||||
client.brpop(timeout, keys);
|
||||
return getResponse(BuilderFactory.STRING_LIST);
|
||||
}
|
||||
|
||||
public Response<Map<String, String>> brpopMap(int timeout, String... keys) {
|
||||
client.blpop(timeout, keys);
|
||||
return getResponse(BuilderFactory.STRING_MAP);
|
||||
}
|
||||
|
||||
public Response<List<byte[]>> blpop(byte[]... args) {
|
||||
client.blpop(args);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_LIST);
|
||||
}
|
||||
|
||||
public Response<List<String>> blpop(int timeout, byte[]... keys) {
|
||||
client.blpop(timeout, keys);
|
||||
return getResponse(BuilderFactory.STRING_LIST);
|
||||
}
|
||||
|
||||
public Response<Long> del(String... keys) {
|
||||
client.del(keys);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> del(byte[]... keys) {
|
||||
client.del(keys);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Set<String>> keys(String pattern) {
|
||||
getClient(pattern).keys(pattern);
|
||||
return getResponse(BuilderFactory.STRING_SET);
|
||||
}
|
||||
|
||||
public Response<Set<byte[]>> keys(byte[] pattern) {
|
||||
getClient(pattern).keys(pattern);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_ZSET);
|
||||
}
|
||||
|
||||
public Response<List<String>> mget(String... keys) {
|
||||
client.mget(keys);
|
||||
return getResponse(BuilderFactory.STRING_LIST);
|
||||
}
|
||||
|
||||
public Response<List<byte[]>> mget(byte[]... keys) {
|
||||
client.mget(keys);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_LIST);
|
||||
}
|
||||
|
||||
public Response<String> mset(String... keysvalues) {
|
||||
client.mset(keysvalues);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<String> mset(byte[]... keysvalues) {
|
||||
client.mset(keysvalues);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Long> msetnx(String... keysvalues) {
|
||||
client.msetnx(keysvalues);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> msetnx(byte[]... keysvalues) {
|
||||
client.msetnx(keysvalues);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<String> rename(String oldkey, String newkey) {
|
||||
client.rename(oldkey, newkey);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<String> rename(byte[] oldkey, byte[] newkey) {
|
||||
client.rename(oldkey, newkey);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Long> renamenx(String oldkey, String newkey) {
|
||||
client.renamenx(oldkey, newkey);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> renamenx(byte[] oldkey, byte[] newkey) {
|
||||
client.renamenx(oldkey, newkey);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<String> rpoplpush(String srckey, String dstkey) {
|
||||
client.rpoplpush(srckey, dstkey);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<byte[]> rpoplpush(byte[] srckey, byte[] dstkey) {
|
||||
client.rpoplpush(srckey, dstkey);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY);
|
||||
}
|
||||
|
||||
public Response<Set<String>> sdiff(String... keys) {
|
||||
client.sdiff(keys);
|
||||
return getResponse(BuilderFactory.STRING_SET);
|
||||
}
|
||||
|
||||
public Response<Set<byte[]>> sdiff(byte[]... keys) {
|
||||
client.sdiff(keys);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_ZSET);
|
||||
}
|
||||
|
||||
public Response<Long> sdiffstore(String dstkey, String... keys) {
|
||||
client.sdiffstore(dstkey, keys);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> sdiffstore(byte[] dstkey, byte[]... keys) {
|
||||
client.sdiffstore(dstkey, keys);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Set<String>> sinter(String... keys) {
|
||||
client.sinter(keys);
|
||||
return getResponse(BuilderFactory.STRING_SET);
|
||||
}
|
||||
|
||||
public Response<Set<byte[]>> sinter(byte[]... keys) {
|
||||
client.sinter(keys);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_ZSET);
|
||||
}
|
||||
|
||||
public Response<Long> sinterstore(String dstkey, String... keys) {
|
||||
client.sinterstore(dstkey, keys);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> sinterstore(byte[] dstkey, byte[]... keys) {
|
||||
client.sinterstore(dstkey, keys);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> smove(String srckey, String dstkey, String member) {
|
||||
client.smove(srckey, dstkey, member);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> smove(byte[] srckey, byte[] dstkey, byte[] member) {
|
||||
client.smove(srckey, dstkey, member);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> sort(String key,
|
||||
SortingParams sortingParameters, String dstkey) {
|
||||
client.sort(key, sortingParameters, dstkey);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> sort(byte[] key,
|
||||
SortingParams sortingParameters, byte[] dstkey) {
|
||||
client.sort(key, sortingParameters, dstkey);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> sort(String key, String dstkey) {
|
||||
client.sort(key, dstkey);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> sort(byte[] key, byte[] dstkey) {
|
||||
client.sort(key, dstkey);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Set<String>> sunion(String... keys) {
|
||||
client.sunion(keys);
|
||||
return getResponse(BuilderFactory.STRING_SET);
|
||||
}
|
||||
|
||||
public Response<Set<byte[]>> sunion(byte[]... keys) {
|
||||
client.sunion(keys);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY_ZSET);
|
||||
}
|
||||
|
||||
public Response<Long> sunionstore(String dstkey, String... keys) {
|
||||
client.sunionstore(dstkey, keys);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> sunionstore(byte[] dstkey, byte[]... keys) {
|
||||
client.sunionstore(dstkey, keys);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<String> watch(String... keys) {
|
||||
client.watch(keys);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<String> watch(byte[]... keys) {
|
||||
client.watch(keys);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Long> zinterstore(String dstkey, String... sets) {
|
||||
client.zinterstore(dstkey, sets);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> zinterstore(byte[] dstkey, byte[]... sets) {
|
||||
client.zinterstore(dstkey, sets);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> zinterstore(String dstkey, ZParams params,
|
||||
String... sets) {
|
||||
client.zinterstore(dstkey, params, sets);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> zinterstore(byte[] dstkey, ZParams params,
|
||||
byte[]... sets) {
|
||||
client.zinterstore(dstkey, params, sets);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> zunionstore(String dstkey, String... sets) {
|
||||
client.zunionstore(dstkey, sets);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> zunionstore(byte[] dstkey, byte[]... sets) {
|
||||
client.zunionstore(dstkey, sets);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> zunionstore(String dstkey, ZParams params,
|
||||
String... sets) {
|
||||
client.zunionstore(dstkey, params, sets);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> zunionstore(byte[] dstkey, ZParams params,
|
||||
byte[]... sets) {
|
||||
client.zunionstore(dstkey, params, sets);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<String> bgrewriteaof() {
|
||||
client.bgrewriteaof();
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<String> bgsave() {
|
||||
client.bgsave();
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<String> configGet(String pattern) {
|
||||
client.configGet(pattern);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<String> configSet(String parameter, String value) {
|
||||
client.configSet(parameter, value);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<String> brpoplpush(String source, String destination,
|
||||
int timeout) {
|
||||
client.brpoplpush(source, destination, timeout);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<byte[]> brpoplpush(byte[] source, byte[] destination,
|
||||
int timeout) {
|
||||
client.brpoplpush(source, destination, timeout);
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY);
|
||||
}
|
||||
|
||||
public Response<String> configResetStat() {
|
||||
client.configResetStat();
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<String> save() {
|
||||
client.save();
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Long> lastsave() {
|
||||
client.lastsave();
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> publish(String channel, String message) {
|
||||
client.publish(channel, message);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> publish(byte[] channel, byte[] message) {
|
||||
client.publish(channel, message);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<String> randomKey() {
|
||||
client.randomKey();
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<byte[]> randomKeyBinary() {
|
||||
client.randomKey();
|
||||
return getResponse(BuilderFactory.BYTE_ARRAY);
|
||||
}
|
||||
|
||||
public Response<String> flushDB() {
|
||||
client.flushDB();
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<String> flushAll() {
|
||||
client.flushAll();
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<String> info() {
|
||||
client.info();
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Long> dbSize() {
|
||||
client.dbSize();
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<String> shutdown() {
|
||||
client.shutdown();
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<String> ping() {
|
||||
client.ping();
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<String> select(int index) {
|
||||
client.select(index);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Long> bitop(BitOP op, byte[] destKey, byte[]... srcKeys) {
|
||||
client.bitop(op, destKey, srcKeys);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> bitop(BitOP op, String destKey, String... srcKeys) {
|
||||
client.bitop(op, destKey, srcKeys);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
}
|
||||
1206
src/main/java/redis/clients/jedis/Pipeline.java
Normal file → Executable file
1206
src/main/java/redis/clients/jedis/Pipeline.java
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
1162
src/main/java/redis/clients/jedis/PipelineBase.java
Normal file
1162
src/main/java/redis/clients/jedis/PipelineBase.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -14,6 +14,7 @@ public final class Protocol {
|
||||
|
||||
public static final int DEFAULT_PORT = 6379;
|
||||
public static final int DEFAULT_TIMEOUT = 2000;
|
||||
public static final int DEFAULT_DATABASE = 0;
|
||||
|
||||
public static final String CHARSET = "UTF-8";
|
||||
|
||||
@@ -23,134 +24,153 @@ public final class Protocol {
|
||||
public static final byte MINUS_BYTE = '-';
|
||||
public static final byte COLON_BYTE = ':';
|
||||
|
||||
public void sendCommand(final RedisOutputStream os, final Command command,
|
||||
final byte[]... args) {
|
||||
sendCommand(os, command.raw, args);
|
||||
public static final String SENTINEL_MASTERS = "masters";
|
||||
public static final String SENTINEL_GET_MASTER_ADDR_BY_NAME = "get-master-addr-by-name";
|
||||
public static final String SENTINEL_RESET = "reset";
|
||||
public static final String SENTINEL_SLAVES = "slaves";
|
||||
public static final String SENTINEL_IS_MASTER_DOWN_BY_ADDR = "is-master-down-by-addr";
|
||||
|
||||
private Protocol() {
|
||||
// this prevent the class from instantiation
|
||||
}
|
||||
|
||||
private void sendCommand(final RedisOutputStream os, final byte[] command,
|
||||
final byte[]... args) {
|
||||
try {
|
||||
os.write(ASTERISK_BYTE);
|
||||
os.writeIntCrLf(args.length + 1);
|
||||
os.write(DOLLAR_BYTE);
|
||||
os.writeIntCrLf(command.length);
|
||||
os.write(command);
|
||||
os.writeCrLf();
|
||||
|
||||
for (final byte[] arg : args) {
|
||||
os.write(DOLLAR_BYTE);
|
||||
os.writeIntCrLf(arg.length);
|
||||
os.write(arg);
|
||||
os.writeCrLf();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new JedisConnectionException(e);
|
||||
}
|
||||
public static void sendCommand(final RedisOutputStream os,
|
||||
final Command command, final byte[]... args) {
|
||||
sendCommand(os, command.raw, args);
|
||||
}
|
||||
|
||||
private void processError(final RedisInputStream is) {
|
||||
String message = is.readLine();
|
||||
throw new JedisDataException(message);
|
||||
private static void sendCommand(final RedisOutputStream os,
|
||||
final byte[] command, final byte[]... args) {
|
||||
try {
|
||||
os.write(ASTERISK_BYTE);
|
||||
os.writeIntCrLf(args.length + 1);
|
||||
os.write(DOLLAR_BYTE);
|
||||
os.writeIntCrLf(command.length);
|
||||
os.write(command);
|
||||
os.writeCrLf();
|
||||
|
||||
for (final byte[] arg : args) {
|
||||
os.write(DOLLAR_BYTE);
|
||||
os.writeIntCrLf(arg.length);
|
||||
os.write(arg);
|
||||
os.writeCrLf();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new JedisConnectionException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private Object process(final RedisInputStream is) {
|
||||
try {
|
||||
byte b = is.readByte();
|
||||
if (b == MINUS_BYTE) {
|
||||
processError(is);
|
||||
} else if (b == ASTERISK_BYTE) {
|
||||
return processMultiBulkReply(is);
|
||||
} else if (b == COLON_BYTE) {
|
||||
return processInteger(is);
|
||||
} else if (b == DOLLAR_BYTE) {
|
||||
return processBulkReply(is);
|
||||
} else if (b == PLUS_BYTE) {
|
||||
return processStatusCodeReply(is);
|
||||
} else {
|
||||
throw new JedisConnectionException("Unknown reply: " + (char) b);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new JedisConnectionException(e);
|
||||
}
|
||||
return null;
|
||||
private static void processError(final RedisInputStream is) {
|
||||
String message = is.readLine();
|
||||
throw new JedisDataException(message);
|
||||
}
|
||||
|
||||
private byte[] processStatusCodeReply(final RedisInputStream is) {
|
||||
return SafeEncoder.encode(is.readLine());
|
||||
private static Object process(final RedisInputStream is) {
|
||||
try {
|
||||
byte b = is.readByte();
|
||||
if (b == MINUS_BYTE) {
|
||||
processError(is);
|
||||
} else if (b == ASTERISK_BYTE) {
|
||||
return processMultiBulkReply(is);
|
||||
} else if (b == COLON_BYTE) {
|
||||
return processInteger(is);
|
||||
} else if (b == DOLLAR_BYTE) {
|
||||
return processBulkReply(is);
|
||||
} else if (b == PLUS_BYTE) {
|
||||
return processStatusCodeReply(is);
|
||||
} else {
|
||||
throw new JedisConnectionException("Unknown reply: " + (char) b);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new JedisConnectionException(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private byte[] processBulkReply(final RedisInputStream is) {
|
||||
int len = Integer.parseInt(is.readLine());
|
||||
if (len == -1) {
|
||||
return null;
|
||||
}
|
||||
byte[] read = new byte[len];
|
||||
int offset = 0;
|
||||
try {
|
||||
while (offset < len) {
|
||||
offset += is.read(read, offset, (len - offset));
|
||||
}
|
||||
// read 2 more bytes for the command delimiter
|
||||
is.readByte();
|
||||
is.readByte();
|
||||
} catch (IOException e) {
|
||||
throw new JedisConnectionException(e);
|
||||
}
|
||||
|
||||
return read;
|
||||
private static byte[] processStatusCodeReply(final RedisInputStream is) {
|
||||
return SafeEncoder.encode(is.readLine());
|
||||
}
|
||||
|
||||
private Long processInteger(final RedisInputStream is) {
|
||||
String num = is.readLine();
|
||||
return Long.valueOf(num);
|
||||
private static byte[] processBulkReply(final RedisInputStream is) {
|
||||
int len = Integer.parseInt(is.readLine());
|
||||
if (len == -1) {
|
||||
return null;
|
||||
}
|
||||
byte[] read = new byte[len];
|
||||
int offset = 0;
|
||||
try {
|
||||
while (offset < len) {
|
||||
offset += is.read(read, offset, (len - offset));
|
||||
}
|
||||
// read 2 more bytes for the command delimiter
|
||||
is.readByte();
|
||||
is.readByte();
|
||||
} catch (IOException e) {
|
||||
throw new JedisConnectionException(e);
|
||||
}
|
||||
|
||||
return read;
|
||||
}
|
||||
|
||||
private List<Object> processMultiBulkReply(final RedisInputStream is) {
|
||||
int num = Integer.parseInt(is.readLine());
|
||||
if (num == -1) {
|
||||
return null;
|
||||
}
|
||||
List<Object> ret = new ArrayList<Object>(num);
|
||||
for (int i = 0; i < num; i++) {
|
||||
ret.add(process(is));
|
||||
}
|
||||
return ret;
|
||||
private static Long processInteger(final RedisInputStream is) {
|
||||
String num = is.readLine();
|
||||
return Long.valueOf(num);
|
||||
}
|
||||
|
||||
public Object read(final RedisInputStream is) {
|
||||
return process(is);
|
||||
private static List<Object> processMultiBulkReply(final RedisInputStream is) {
|
||||
int num = Integer.parseInt(is.readLine());
|
||||
if (num == -1) {
|
||||
return null;
|
||||
}
|
||||
List<Object> ret = new ArrayList<Object>(num);
|
||||
for (int i = 0; i < num; i++) {
|
||||
try {
|
||||
ret.add(process(is));
|
||||
} catch (JedisDataException e) {
|
||||
ret.add(e);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Object read(final RedisInputStream is) {
|
||||
return process(is);
|
||||
}
|
||||
|
||||
public static final byte[] toByteArray(final boolean value) {
|
||||
return toByteArray(value ? 1 : 0);
|
||||
}
|
||||
|
||||
public static final byte[] toByteArray(final int value) {
|
||||
return SafeEncoder.encode(String.valueOf(value));
|
||||
return SafeEncoder.encode(String.valueOf(value));
|
||||
}
|
||||
|
||||
public static final byte[] toByteArray(final long value) {
|
||||
return SafeEncoder.encode(String.valueOf(value));
|
||||
return SafeEncoder.encode(String.valueOf(value));
|
||||
}
|
||||
|
||||
public static final byte[] toByteArray(final double value) {
|
||||
return SafeEncoder.encode(String.valueOf(value));
|
||||
return SafeEncoder.encode(String.valueOf(value));
|
||||
}
|
||||
|
||||
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, 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;
|
||||
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, EVAL, EVALSHA, SCRIPT, SLOWLOG, OBJECT, BITCOUNT, BITOP, SENTINEL,
|
||||
DUMP, RESTORE, PEXPIRE, PEXPIREAT, PTTL, INCRBYFLOAT, PSETEX, CLIENT, TIME, MIGRATE, HINCRBYFLOAT;
|
||||
|
||||
public final byte[] raw;
|
||||
public final byte[] raw;
|
||||
|
||||
Command() {
|
||||
raw = SafeEncoder.encode(this.name());
|
||||
}
|
||||
Command() {
|
||||
raw = SafeEncoder.encode(this.name());
|
||||
}
|
||||
}
|
||||
|
||||
public static enum Keyword {
|
||||
AGGREGATE, ALPHA, ASC, BY, DESC, GET, LIMIT, MESSAGE, NO, NOSORT, PMESSAGE, PSUBSCRIBE, PUNSUBSCRIBE, OK, ONE, QUEUED, SET, STORE, SUBSCRIBE, UNSUBSCRIBE, WEIGHTS, WITHSCORES, RESETSTAT;
|
||||
public final byte[] raw;
|
||||
|
||||
Keyword() {
|
||||
raw = SafeEncoder.encode(this.name().toLowerCase());
|
||||
}
|
||||
AGGREGATE, ALPHA, ASC, BY, DESC, GET, LIMIT, MESSAGE, NO, NOSORT, PMESSAGE, PSUBSCRIBE, PUNSUBSCRIBE, OK, ONE, QUEUED, SET, STORE, SUBSCRIBE, UNSUBSCRIBE, WEIGHTS, WITHSCORES, RESETSTAT, RESET, FLUSH, EXISTS, LOAD, KILL, LEN, REFCOUNT, ENCODING, IDLETIME, AND, OR, XOR, NOT,
|
||||
GETNAME, SETNAME,LIST;
|
||||
public final byte[] raw;
|
||||
|
||||
Keyword() {
|
||||
raw = SafeEncoder.encode(this.name().toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
200
src/main/java/redis/clients/jedis/RedisPipeline.java
Normal file
200
src/main/java/redis/clients/jedis/RedisPipeline.java
Normal file
@@ -0,0 +1,200 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author guy
|
||||
*/
|
||||
public interface RedisPipeline {
|
||||
Response<Long> append(String key, String value);
|
||||
|
||||
Response<List<String>> blpop(String arg);
|
||||
|
||||
Response<List<String>> brpop(String arg);
|
||||
|
||||
Response<Long> decr(String key);
|
||||
|
||||
Response<Long> decrBy(String key, long integer);
|
||||
|
||||
Response<Long> del(String key);
|
||||
|
||||
Response<String> echo(String string);
|
||||
|
||||
Response<Boolean> exists(String key);
|
||||
|
||||
Response<Long> expire(String key, int seconds);
|
||||
|
||||
Response<Long> expireAt(String key, long unixTime);
|
||||
|
||||
Response<String> get(String key);
|
||||
|
||||
Response<Boolean> getbit(String key, long offset);
|
||||
|
||||
|
||||
|
||||
Response<String> getrange(String key, long startOffset,
|
||||
long endOffset);
|
||||
|
||||
Response<String> getSet(String key, String value);
|
||||
|
||||
Response<Long> hdel(String key, String... field);
|
||||
|
||||
Response<Boolean> hexists(String key, String field);
|
||||
|
||||
Response<String> hget(String key, String field);
|
||||
|
||||
Response<Map<String, String>> hgetAll(String key);
|
||||
|
||||
Response<Long> hincrBy(String key, String field, long value);
|
||||
|
||||
Response<Set<String>> hkeys(String key);
|
||||
|
||||
Response<Long> hlen(String key);
|
||||
|
||||
Response<List<String>> hmget(String key, String... fields);
|
||||
|
||||
Response<String> hmset(String key, Map<String, String> hash);
|
||||
|
||||
Response<Long> hset(String key, String field, String value);
|
||||
|
||||
Response<Long> hsetnx(String key, String field, String value);
|
||||
|
||||
Response<List<String>> hvals(String key);
|
||||
|
||||
Response<Long> incr(String key);
|
||||
|
||||
Response<Long> incrBy(String key, long integer);
|
||||
|
||||
Response<String> lindex(String key, long index);
|
||||
|
||||
Response<Long> linsert(String key, BinaryClient.LIST_POSITION where,
|
||||
String pivot, String value);
|
||||
|
||||
Response<Long> llen(String key);
|
||||
|
||||
Response<String> lpop(String key);
|
||||
|
||||
Response<Long> lpush(String key, String... string);
|
||||
|
||||
Response<Long> lpushx(String key, String... string);
|
||||
|
||||
Response<List<String>> lrange(String key, long start, long end);
|
||||
|
||||
Response<Long> lrem(String key, long count, String value);
|
||||
|
||||
Response<String> lset(String key, long index, String value);
|
||||
|
||||
Response<String> ltrim(String key, long start, long end);
|
||||
|
||||
Response<Long> move(String key, int dbIndex);
|
||||
|
||||
Response<Long> persist(String key);
|
||||
|
||||
Response<String> rpop(String key);
|
||||
|
||||
Response<Long> rpush(String key, String... string);
|
||||
|
||||
Response<Long> rpushx(String key, String... string);
|
||||
|
||||
Response<Long> sadd(String key, String... member);
|
||||
|
||||
Response<Long> scard(String key);
|
||||
|
||||
Response<Boolean> sismember(String key, String member);
|
||||
|
||||
Response<String> set(String key, String value);
|
||||
|
||||
Response<Boolean> setbit(String key, long offset, boolean value);
|
||||
|
||||
Response<String> setex(String key, int seconds, String value);
|
||||
|
||||
Response<Long> setnx(String key, String value);
|
||||
|
||||
Response<Long> setrange(String key, long offset, String value);
|
||||
|
||||
Response<Set<String>> smembers(String key);
|
||||
|
||||
Response<List<String>> sort(String key);
|
||||
|
||||
Response<List<String>> sort(String key,
|
||||
SortingParams sortingParameters);
|
||||
|
||||
Response<String> spop(String key);
|
||||
|
||||
Response<String> srandmember(String key);
|
||||
|
||||
Response<Long> srem(String key, String... member);
|
||||
|
||||
Response<Long> strlen(String key);
|
||||
|
||||
Response<String> substr(String key, int start, int end);
|
||||
|
||||
Response<Long> ttl(String key);
|
||||
|
||||
Response<String> type(String key);
|
||||
|
||||
Response<Long> zadd(String key, double score, String member);
|
||||
|
||||
Response<Long> zcard(String key);
|
||||
|
||||
Response<Long> zcount(String key, double min, double max);
|
||||
|
||||
Response<Double> zincrby(String key, double score, String member);
|
||||
|
||||
Response<Set<String>> zrange(String key, long start, long end);
|
||||
|
||||
Response<Set<String>> zrangeByScore(String key, double min,
|
||||
double max);
|
||||
|
||||
Response<Set<String>> zrangeByScore(String key, String min,
|
||||
String max);
|
||||
|
||||
Response<Set<String>> zrangeByScore(String key, double min,
|
||||
double max, int offset, int count);
|
||||
|
||||
Response<Set<Tuple>> zrangeByScoreWithScores(String key, double min,
|
||||
double max);
|
||||
|
||||
Response<Set<Tuple>> zrangeByScoreWithScores(String key, double min,
|
||||
double max, int offset, int count);
|
||||
|
||||
Response<Set<String>> zrevrangeByScore(String key, double max,
|
||||
double min);
|
||||
|
||||
Response<Set<String>> zrevrangeByScore(String key, String max,
|
||||
String min);
|
||||
|
||||
Response<Set<String>> zrevrangeByScore(String key, double max,
|
||||
double min, int offset, int count);
|
||||
|
||||
Response<Set<Tuple>> zrevrangeByScoreWithScores(String key,
|
||||
double max, double min);
|
||||
|
||||
Response<Set<Tuple>> zrevrangeByScoreWithScores(String key,
|
||||
double max, double min, int offset, int count);
|
||||
|
||||
Response<Set<Tuple>> zrangeWithScores(String key, long start, long end);
|
||||
|
||||
Response<Long> zrank(String key, String member);
|
||||
|
||||
Response<Long> zrem(String key, String... member);
|
||||
|
||||
Response<Long> zremrangeByRank(String key, long start, long end);
|
||||
|
||||
Response<Long> zremrangeByScore(String key, double start, double end);
|
||||
|
||||
Response<Set<String>> zrevrange(String key, long start, long end);
|
||||
|
||||
Response<Set<Tuple>> zrevrangeWithScores(String key, long start,
|
||||
long end);
|
||||
|
||||
Response<Long> zrevrank(String key, String member);
|
||||
|
||||
Response<Double> zscore(String key, String member);
|
||||
|
||||
Response<Long> bitcount(String key);
|
||||
|
||||
Response<Long> bitcount(String key, long start, long end);
|
||||
}
|
||||
@@ -24,7 +24,12 @@ public class Response<T> {
|
||||
"Please close pipeline or multi block before calling this method.");
|
||||
}
|
||||
if (!built) {
|
||||
response = builder.build(data);
|
||||
if(data != null ){
|
||||
if (data instanceof JedisDataException){
|
||||
throw new JedisDataException((JedisDataException)data);
|
||||
}
|
||||
response = builder.build(data);
|
||||
}
|
||||
this.data = null;
|
||||
built = true;
|
||||
}
|
||||
|
||||
23
src/main/java/redis/clients/jedis/ScriptingCommands.java
Normal file
23
src/main/java/redis/clients/jedis/ScriptingCommands.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ScriptingCommands {
|
||||
Object eval(String script, int keyCount, String... params);
|
||||
|
||||
Object eval(String script, List<String> keys, List<String> args);
|
||||
|
||||
Object eval(String script);
|
||||
|
||||
Object evalsha(String script);
|
||||
|
||||
Object evalsha(String sha1, List<String> keys, List<String> args);
|
||||
|
||||
Object evalsha(String sha1, int keyCount, String... params);
|
||||
|
||||
Boolean scriptExists(String sha1);
|
||||
|
||||
List<Boolean> scriptExists(String... sha1);
|
||||
|
||||
String scriptLoad(String script);
|
||||
}
|
||||
@@ -1,416 +1,526 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
import redis.clients.jedis.BinaryClient.LIST_POSITION;
|
||||
import redis.clients.util.Hashing;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import redis.clients.jedis.BinaryClient.LIST_POSITION;
|
||||
import redis.clients.util.Hashing;
|
||||
|
||||
public class ShardedJedis extends BinaryShardedJedis implements JedisCommands {
|
||||
public ShardedJedis(List<JedisShardInfo> shards) {
|
||||
super(shards);
|
||||
super(shards);
|
||||
}
|
||||
|
||||
public ShardedJedis(List<JedisShardInfo> shards, Hashing algo) {
|
||||
super(shards, algo);
|
||||
super(shards, algo);
|
||||
}
|
||||
|
||||
public ShardedJedis(List<JedisShardInfo> shards, Pattern keyTagPattern) {
|
||||
super(shards, keyTagPattern);
|
||||
super(shards, keyTagPattern);
|
||||
}
|
||||
|
||||
public ShardedJedis(List<JedisShardInfo> shards, Hashing algo,
|
||||
Pattern keyTagPattern) {
|
||||
super(shards, algo, keyTagPattern);
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
for (Jedis jedis : getAllShards()) {
|
||||
jedis.quit();
|
||||
jedis.disconnect();
|
||||
}
|
||||
Pattern keyTagPattern) {
|
||||
super(shards, algo, keyTagPattern);
|
||||
}
|
||||
|
||||
public String set(String key, String value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.set(key, value);
|
||||
Jedis j = getShard(key);
|
||||
return j.set(key, value);
|
||||
}
|
||||
|
||||
public String get(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.get(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.get(key);
|
||||
}
|
||||
|
||||
public String echo(String string) {
|
||||
Jedis j = getShard(string);
|
||||
return j.echo(string);
|
||||
}
|
||||
|
||||
public Boolean exists(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.exists(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.exists(key);
|
||||
}
|
||||
|
||||
public String type(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.type(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.type(key);
|
||||
}
|
||||
|
||||
public Long expire(String key, int seconds) {
|
||||
Jedis j = getShard(key);
|
||||
return j.expire(key, seconds);
|
||||
Jedis j = getShard(key);
|
||||
return j.expire(key, seconds);
|
||||
}
|
||||
|
||||
public Long expireAt(String key, long unixTime) {
|
||||
Jedis j = getShard(key);
|
||||
return j.expireAt(key, unixTime);
|
||||
Jedis j = getShard(key);
|
||||
return j.expireAt(key, unixTime);
|
||||
}
|
||||
|
||||
public Long ttl(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.ttl(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.ttl(key);
|
||||
}
|
||||
|
||||
public boolean setbit(String key, long offset, boolean value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.setbit(key, offset, value);
|
||||
public Boolean setbit(String key, long offset, boolean value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.setbit(key, offset, value);
|
||||
}
|
||||
|
||||
public boolean getbit(String key, long offset) {
|
||||
Jedis j = getShard(key);
|
||||
return j.getbit(key, offset);
|
||||
public Boolean setbit(String key, long offset, String value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.setbit(key, offset, value);
|
||||
}
|
||||
|
||||
public long setrange(String key, long offset, String value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.setrange(key, offset, value);
|
||||
public Boolean getbit(String key, long offset) {
|
||||
Jedis j = getShard(key);
|
||||
return j.getbit(key, offset);
|
||||
}
|
||||
|
||||
public Long setrange(String key, long offset, String value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.setrange(key, offset, value);
|
||||
}
|
||||
|
||||
public String getrange(String key, long startOffset, long endOffset) {
|
||||
Jedis j = getShard(key);
|
||||
return j.getrange(key, startOffset, endOffset);
|
||||
Jedis j = getShard(key);
|
||||
return j.getrange(key, startOffset, endOffset);
|
||||
}
|
||||
|
||||
public String getSet(String key, String value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.getSet(key, value);
|
||||
Jedis j = getShard(key);
|
||||
return j.getSet(key, value);
|
||||
}
|
||||
|
||||
public Long setnx(String key, String value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.setnx(key, value);
|
||||
Jedis j = getShard(key);
|
||||
return j.setnx(key, value);
|
||||
}
|
||||
|
||||
public String setex(String key, int seconds, String value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.setex(key, seconds, value);
|
||||
Jedis j = getShard(key);
|
||||
return j.setex(key, seconds, value);
|
||||
}
|
||||
|
||||
public List<String> blpop(String arg) {
|
||||
Jedis j = getShard(arg);
|
||||
return j.blpop(arg);
|
||||
}
|
||||
|
||||
public List<String> brpop(String arg) {
|
||||
Jedis j = getShard(arg);
|
||||
return j.brpop(arg);
|
||||
}
|
||||
|
||||
public Long decrBy(String key, long integer) {
|
||||
Jedis j = getShard(key);
|
||||
return j.decrBy(key, integer);
|
||||
Jedis j = getShard(key);
|
||||
return j.decrBy(key, integer);
|
||||
}
|
||||
|
||||
public Long decr(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.decr(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.decr(key);
|
||||
}
|
||||
|
||||
public Long incrBy(String key, long integer) {
|
||||
Jedis j = getShard(key);
|
||||
return j.incrBy(key, integer);
|
||||
Jedis j = getShard(key);
|
||||
return j.incrBy(key, integer);
|
||||
}
|
||||
|
||||
public Long incr(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.incr(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.incr(key);
|
||||
}
|
||||
|
||||
public Long append(String key, String value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.append(key, value);
|
||||
Jedis j = getShard(key);
|
||||
return j.append(key, value);
|
||||
}
|
||||
|
||||
public String substr(String key, int start, int end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.substr(key, start, end);
|
||||
Jedis j = getShard(key);
|
||||
return j.substr(key, start, end);
|
||||
}
|
||||
|
||||
public Long hset(String key, String field, String value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hset(key, field, value);
|
||||
Jedis j = getShard(key);
|
||||
return j.hset(key, field, value);
|
||||
}
|
||||
|
||||
public String hget(String key, String field) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hget(key, field);
|
||||
Jedis j = getShard(key);
|
||||
return j.hget(key, field);
|
||||
}
|
||||
|
||||
public Long hsetnx(String key, String field, String value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hsetnx(key, field, value);
|
||||
Jedis j = getShard(key);
|
||||
return j.hsetnx(key, field, value);
|
||||
}
|
||||
|
||||
public String hmset(String key, Map<String, String> hash) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hmset(key, hash);
|
||||
Jedis j = getShard(key);
|
||||
return j.hmset(key, hash);
|
||||
}
|
||||
|
||||
public List<String> hmget(String key, String... fields) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hmget(key, fields);
|
||||
Jedis j = getShard(key);
|
||||
return j.hmget(key, fields);
|
||||
}
|
||||
|
||||
public Long hincrBy(String key, String field, long value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hincrBy(key, field, value);
|
||||
Jedis j = getShard(key);
|
||||
return j.hincrBy(key, field, value);
|
||||
}
|
||||
|
||||
public Boolean hexists(String key, String field) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hexists(key, field);
|
||||
Jedis j = getShard(key);
|
||||
return j.hexists(key, field);
|
||||
}
|
||||
|
||||
public Long del(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.del(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.del(key);
|
||||
}
|
||||
|
||||
public Long hdel(String key, String field) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hdel(key, field);
|
||||
public Long hdel(String key, String... fields) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hdel(key, fields);
|
||||
}
|
||||
|
||||
public Long hlen(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hlen(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.hlen(key);
|
||||
}
|
||||
|
||||
public Set<String> hkeys(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hkeys(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.hkeys(key);
|
||||
}
|
||||
|
||||
public List<String> hvals(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hvals(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.hvals(key);
|
||||
}
|
||||
|
||||
public Map<String, String> hgetAll(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hgetAll(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.hgetAll(key);
|
||||
}
|
||||
|
||||
public Long rpush(String key, String string) {
|
||||
Jedis j = getShard(key);
|
||||
return j.rpush(key, string);
|
||||
public Long rpush(String key, String... strings) {
|
||||
Jedis j = getShard(key);
|
||||
return j.rpush(key, strings);
|
||||
}
|
||||
|
||||
public Long lpush(String key, String string) {
|
||||
public Long lpush(String key, String... strings) {
|
||||
Jedis j = getShard(key);
|
||||
return j.lpush(key, strings);
|
||||
}
|
||||
|
||||
public Long lpushx(String key, String... string) {
|
||||
Jedis j = getShard(key);
|
||||
return j.lpushx(key, string);
|
||||
}
|
||||
|
||||
public Long strlen(final String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.strlen(key);
|
||||
}
|
||||
|
||||
public Long move(String key, int dbIndex) {
|
||||
Jedis j = getShard(key);
|
||||
return j.lpush(key, string);
|
||||
return j.move(key, dbIndex);
|
||||
}
|
||||
|
||||
public Long rpushx(String key, String... string) {
|
||||
Jedis j = getShard(key);
|
||||
return j.rpushx(key, string);
|
||||
}
|
||||
|
||||
public Long persist(final String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.persist(key);
|
||||
}
|
||||
|
||||
public Long llen(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.llen(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.llen(key);
|
||||
}
|
||||
|
||||
public List<String> lrange(String key, long start, long end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.lrange(key, start, end);
|
||||
Jedis j = getShard(key);
|
||||
return j.lrange(key, start, end);
|
||||
}
|
||||
|
||||
public String ltrim(String key, long start, long end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.ltrim(key, start, end);
|
||||
Jedis j = getShard(key);
|
||||
return j.ltrim(key, start, end);
|
||||
}
|
||||
|
||||
public String lindex(String key, long index) {
|
||||
Jedis j = getShard(key);
|
||||
return j.lindex(key, index);
|
||||
Jedis j = getShard(key);
|
||||
return j.lindex(key, index);
|
||||
}
|
||||
|
||||
public String lset(String key, long index, String value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.lset(key, index, value);
|
||||
Jedis j = getShard(key);
|
||||
return j.lset(key, index, value);
|
||||
}
|
||||
|
||||
public Long lrem(String key, long count, String value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.lrem(key, count, value);
|
||||
Jedis j = getShard(key);
|
||||
return j.lrem(key, count, value);
|
||||
}
|
||||
|
||||
public String lpop(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.lpop(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.lpop(key);
|
||||
}
|
||||
|
||||
public String rpop(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.rpop(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.rpop(key);
|
||||
}
|
||||
|
||||
public Long sadd(String key, String member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.sadd(key, member);
|
||||
public Long sadd(String key, String... members) {
|
||||
Jedis j = getShard(key);
|
||||
return j.sadd(key, members);
|
||||
}
|
||||
|
||||
public Set<String> smembers(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.smembers(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.smembers(key);
|
||||
}
|
||||
|
||||
public Long srem(String key, String member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.srem(key, member);
|
||||
public Long srem(String key, String... members) {
|
||||
Jedis j = getShard(key);
|
||||
return j.srem(key, members);
|
||||
}
|
||||
|
||||
public String spop(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.spop(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.spop(key);
|
||||
}
|
||||
|
||||
public Long scard(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.scard(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.scard(key);
|
||||
}
|
||||
|
||||
public Boolean sismember(String key, String member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.sismember(key, member);
|
||||
Jedis j = getShard(key);
|
||||
return j.sismember(key, member);
|
||||
}
|
||||
|
||||
public String srandmember(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.srandmember(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.srandmember(key);
|
||||
}
|
||||
|
||||
public Long zadd(String key, double score, String member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zadd(key, score, member);
|
||||
Jedis j = getShard(key);
|
||||
return j.zadd(key, score, member);
|
||||
}
|
||||
|
||||
public Set<String> zrange(String key, int start, int end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrange(key, start, end);
|
||||
public Long zadd(String key, Map<Double, String> scoreMembers) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zadd(key, scoreMembers);
|
||||
}
|
||||
|
||||
public Long zrem(String key, String member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrem(key, member);
|
||||
public Set<String> zrange(String key, long start, long end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrange(key, start, end);
|
||||
}
|
||||
|
||||
public Long zrem(String key, String... members) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrem(key, members);
|
||||
}
|
||||
|
||||
public Double zincrby(String key, double score, String member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zincrby(key, score, member);
|
||||
Jedis j = getShard(key);
|
||||
return j.zincrby(key, score, member);
|
||||
}
|
||||
|
||||
public Long zrank(String key, String member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrank(key, member);
|
||||
Jedis j = getShard(key);
|
||||
return j.zrank(key, member);
|
||||
}
|
||||
|
||||
public Long zrevrank(String key, String member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrank(key, member);
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrank(key, member);
|
||||
}
|
||||
|
||||
public Set<String> zrevrange(String key, int start, int end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrange(key, start, end);
|
||||
public Set<String> zrevrange(String key, long start, long end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrange(key, start, end);
|
||||
}
|
||||
|
||||
public Set<Tuple> zrangeWithScores(String key, int start, int end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrangeWithScores(key, start, end);
|
||||
public Set<Tuple> zrangeWithScores(String key, long start, long end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrangeWithScores(key, start, end);
|
||||
}
|
||||
|
||||
public Set<Tuple> zrevrangeWithScores(String key, int start, int end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrangeWithScores(key, start, end);
|
||||
public Set<Tuple> zrevrangeWithScores(String key, long start, long end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrangeWithScores(key, start, end);
|
||||
}
|
||||
|
||||
public Long zcard(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zcard(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.zcard(key);
|
||||
}
|
||||
|
||||
public Double zscore(String key, String member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zscore(key, member);
|
||||
Jedis j = getShard(key);
|
||||
return j.zscore(key, member);
|
||||
}
|
||||
|
||||
public List<String> sort(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.sort(key);
|
||||
Jedis j = getShard(key);
|
||||
return j.sort(key);
|
||||
}
|
||||
|
||||
public List<String> sort(String key, SortingParams sortingParameters) {
|
||||
Jedis j = getShard(key);
|
||||
return j.sort(key, sortingParameters);
|
||||
Jedis j = getShard(key);
|
||||
return j.sort(key, sortingParameters);
|
||||
}
|
||||
|
||||
public Long zcount(String key, double min, double max) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zcount(key, min, max);
|
||||
Jedis j = getShard(key);
|
||||
return j.zcount(key, min, max);
|
||||
}
|
||||
|
||||
public Long zcount(String key, String min, String max) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zcount(key, min, max);
|
||||
}
|
||||
|
||||
public Set<String> zrangeByScore(String key, double min, double max) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrangeByScore(key, min, max);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
return j.zremrangeByRank(key, start, end);
|
||||
public Set<String> zrangeByScore(String key, String min, String max) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrangeByScore(key, min, max);
|
||||
}
|
||||
|
||||
public Set<String> zrevrangeByScore(String key, String max, String min) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrangeByScore(key, max, min);
|
||||
}
|
||||
|
||||
public Set<String> zrangeByScore(String key, String min, String max,
|
||||
int offset, int count) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrangeByScore(key, min, max, offset, count);
|
||||
}
|
||||
|
||||
public Set<String> zrevrangeByScore(String key, String max, String min,
|
||||
int offset, int count) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrangeByScore(key, max, min, offset, count);
|
||||
}
|
||||
|
||||
public Set<Tuple> zrangeByScoreWithScores(String key, String min, String max) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrangeByScoreWithScores(key, min, max);
|
||||
}
|
||||
|
||||
public Set<Tuple> zrevrangeByScoreWithScores(String key, String max,
|
||||
String min) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrangeByScoreWithScores(key, max, min);
|
||||
}
|
||||
|
||||
public Set<Tuple> zrangeByScoreWithScores(String key, String min,
|
||||
String max, int offset, int count) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrangeByScoreWithScores(key, min, max, offset, count);
|
||||
}
|
||||
|
||||
public Set<Tuple> zrevrangeByScoreWithScores(String key, String max,
|
||||
String min, int offset, int count) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrangeByScoreWithScores(key, max, min, offset, count);
|
||||
}
|
||||
|
||||
public Long zremrangeByRank(String key, long start, long end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zremrangeByRank(key, start, end);
|
||||
}
|
||||
|
||||
public Long zremrangeByScore(String key, double start, double end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zremrangeByScore(key, start, end);
|
||||
Jedis j = getShard(key);
|
||||
return j.zremrangeByScore(key, start, end);
|
||||
}
|
||||
|
||||
public Long zremrangeByScore(String key, String start, String end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zremrangeByScore(key, start, end);
|
||||
}
|
||||
|
||||
public Long linsert(String key, LIST_POSITION where, String pivot,
|
||||
String value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.linsert(key, where, pivot, value);
|
||||
String value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.linsert(key, where, pivot, value);
|
||||
}
|
||||
|
||||
public Long bitcount(final String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.bitcount(key);
|
||||
}
|
||||
|
||||
public Long bitcount(final String key, long start, long end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.bitcount(key, start, end);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
import redis.clients.jedis.BinaryClient.LIST_POSITION;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
|
||||
public abstract class ShardedJedisPipeline {
|
||||
public class ShardedJedisPipeline extends PipelineBase {
|
||||
private BinaryShardedJedis jedis;
|
||||
private List<FutureResult> results = new ArrayList<FutureResult>();
|
||||
private Queue<Client> clients = new LinkedList<Client>();
|
||||
|
||||
private class FutureResult {
|
||||
private static class FutureResult {
|
||||
private Client client;
|
||||
|
||||
public FutureResult(Client client) {
|
||||
@@ -26,429 +26,6 @@ public abstract class ShardedJedisPipeline {
|
||||
this.jedis = jedis;
|
||||
}
|
||||
|
||||
protected void set(String key, String value) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.set(key, value);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void get(String key) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.get(key);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void exists(String key) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.exists(key);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void type(String key) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.type(key);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void expire(String key, int seconds) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.expire(key, seconds);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void expireAt(String key, long unixTime) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.expireAt(key, unixTime);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void ttl(String key) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.ttl(key);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void getSet(String key, String value) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.getSet(key, value);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void setnx(String key, String value) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.setnx(key, value);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void setex(String key, int seconds, String value) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.setex(key, seconds, value);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void decrBy(String key, int integer) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.decrBy(key, integer);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void decr(String key) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.decr(key);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void incrBy(String key, int integer) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.incrBy(key, integer);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void incr(String key) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.incr(key);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void append(String key, String value) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.append(key, value);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void substr(String key, int start, int end) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.substr(key, start, end);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void hset(String key, String field, String value) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.hset(key, field, value);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void hget(String key, String field) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.hget(key, field);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void hsetnx(String key, String field, String value) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.hsetnx(key, field, value);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void hmset(String key, Map<String, String> hash) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.hmset(key, hash);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void hmget(String key, String... fields) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.hmget(key, fields);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void hincrBy(String key, String field, int value) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.hincrBy(key, field, value);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void hexists(String key, String field) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.hexists(key, field);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void hdel(String key, String field) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.hdel(key, field);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void hlen(String key) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.hlen(key);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void hkeys(String key) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.hkeys(key);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void hvals(String key) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.hvals(key);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void hgetAll(String key) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.hgetAll(key);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void rpush(String key, String string) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.rpush(key, string);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void lpush(String key, String string) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.lpush(key, string);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void llen(String key) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.llen(key);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void lrange(String key, int start, int end) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.lrange(key, start, end);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void ltrim(String key, int start, int end) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.ltrim(key, start, end);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void lindex(String key, int index) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.lindex(key, index);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void lset(String key, int index, String value) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.lset(key, index, value);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void lrem(String key, int count, String value) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.lrem(key, count, value);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void lpop(String key) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.lpop(key);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void rpop(String key) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.rpop(key);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void sadd(String key, String member) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.sadd(key, member);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void smembers(String key) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.smembers(key);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void srem(String key, String member) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.srem(key, member);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void spop(String key) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.spop(key);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void scard(String key) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.scard(key);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void sismember(String key, String member) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.sismember(key, member);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void srandmember(String key) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.srandmember(key);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void zadd(String key, double score, String member) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.zadd(key, score, member);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void zrange(String key, int start, int end) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.zrange(key, start, end);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void zrem(String key, String member) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.zrem(key, member);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void zincrby(String key, double score, String member) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.zincrby(key, score, member);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void zrank(String key, String member) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.zrank(key, member);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void zrevrank(String key, String member) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.zrevrank(key, member);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void zrevrange(String key, int start, int end) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.zrevrange(key, start, end);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void zrangeWithScores(String key, int start, int end) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.zrangeWithScores(key, start, end);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void zrevrangeWithScores(String key, int start, int end) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.zrevrangeWithScores(key, start, end);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void zcard(String key) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.zcard(key);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void zscore(String key, String member) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.zscore(key, member);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void sort(String key) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.sort(key);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void sort(String key, SortingParams sortingParameters) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.sort(key, sortingParameters);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void zcount(String key, double min, double max) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.zcount(key, min, max);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void zrangeByScore(String key, double min, double max) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.zrangeByScore(key, min, max);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void zrangeByScore(String key, double min, double max,
|
||||
int offset, int count) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.zrangeByScore(key, min, max, offset, count);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void zrangeByScoreWithScores(String key, double min, double max) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.zrangeByScoreWithScores(key, min, max);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void zrangeByScoreWithScores(String key, double min, double max,
|
||||
int offset, int count) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.zrangeByScoreWithScores(key, min, max, offset, count);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void zremrangeByRank(String key, int start, int end) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.zremrangeByRank(key, start, end);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void zremrangeByScore(String key, double start, double end) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.zremrangeByScore(key, start, end);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void linsert(String key, LIST_POSITION where, String pivot,
|
||||
String value) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.linsert(key, where, pivot, value);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void getbit(String key, long offset) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.getbit(key, offset);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
public void setbit(String key, long offset, boolean value) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.setbit(key, offset, value);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
public void setrange(String key, long offset, String value) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.setrange(key, offset, value);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
public void getrange(String key, long startOffset, long endOffset) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.getrange(key, startOffset, endOffset);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
public List<Object> getResults() {
|
||||
List<Object> r = new ArrayList<Object>();
|
||||
for (FutureResult fr : results) {
|
||||
@@ -457,5 +34,54 @@ public abstract class ShardedJedisPipeline {
|
||||
return r;
|
||||
}
|
||||
|
||||
public abstract void execute();
|
||||
/**
|
||||
* Syncronize pipeline by reading all responses. This operation closes the
|
||||
* pipeline. In order to get return values from pipelined commands, capture
|
||||
* the different Response<?> of the commands you execute.
|
||||
*/
|
||||
public void sync() {
|
||||
for (Client client : clients) {
|
||||
generateResponse(client.getOne());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Syncronize pipeline by reading all responses. This operation closes the
|
||||
* pipeline. Whenever possible try to avoid using this version and use
|
||||
* ShardedJedisPipeline.sync() as it won't go through all the responses and generate the
|
||||
* right response type (usually it is a waste of time).
|
||||
*
|
||||
* @return A list of all the responses in the order you executed them.
|
||||
*/
|
||||
public List<Object> syncAndReturnAll() {
|
||||
List<Object> formatted = new ArrayList<Object>();
|
||||
for (Client client : clients) {
|
||||
formatted.add(generateResponse(client.getOne()).get());
|
||||
}
|
||||
return formatted;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be removed in Jedis 3.0. Use the methods that return Response's and call
|
||||
* sync().
|
||||
*/
|
||||
@Deprecated
|
||||
public void execute() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Client getClient(String key) {
|
||||
Client client = jedis.getShard(key).getClient();
|
||||
clients.add(client);
|
||||
results.add(new FutureResult(client));
|
||||
return client;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Client getClient(byte[] key) {
|
||||
Client client = jedis.getShard(key).getClient();
|
||||
clients.add(client);
|
||||
results.add(new FutureResult(client));
|
||||
return client;
|
||||
}
|
||||
}
|
||||
@@ -1,580 +1,75 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import redis.clients.jedis.BinaryClient.LIST_POSITION;
|
||||
import redis.clients.jedis.exceptions.JedisDataException;
|
||||
|
||||
public class Transaction extends BinaryTransaction {
|
||||
public Transaction() {
|
||||
/**
|
||||
* Transaction is nearly identical to Pipeline, only differences are the multi/discard behaviors
|
||||
*/
|
||||
public class Transaction extends MultiKeyPipelineBase {
|
||||
|
||||
protected boolean inTransaction = true;
|
||||
|
||||
protected Transaction(){
|
||||
// client will be set later in transaction block
|
||||
}
|
||||
|
||||
public Transaction(final Client client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
public Response<Long> append(String key, String value) {
|
||||
client.append(key, value);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<List<String>> blpop(String... args) {
|
||||
client.blpop(args);
|
||||
return getResponse(BuilderFactory.STRING_LIST);
|
||||
}
|
||||
|
||||
public Response<List<String>> brpop(String... args) {
|
||||
client.brpop(args);
|
||||
return getResponse(BuilderFactory.STRING_LIST);
|
||||
}
|
||||
|
||||
public Response<Long> decr(String key) {
|
||||
client.decr(key);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> decrBy(String key, long integer) {
|
||||
client.decrBy(key, integer);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> del(String... keys) {
|
||||
client.del(keys);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<String> echo(String string) {
|
||||
client.echo(string);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Boolean> exists(String key) {
|
||||
client.exists(key);
|
||||
return getResponse(BuilderFactory.BOOLEAN);
|
||||
}
|
||||
|
||||
public Response<Long> expire(String key, int seconds) {
|
||||
client.expire(key, seconds);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> expireAt(String key, long unixTime) {
|
||||
client.expireAt(key, unixTime);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<String> get(String key) {
|
||||
client.get(key);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Boolean> getbit(String key, long offset) {
|
||||
client.getbit(key, offset);
|
||||
return getResponse(BuilderFactory.BOOLEAN);
|
||||
}
|
||||
|
||||
public Response<String> getrange(String key, long startOffset,
|
||||
long endOffset) {
|
||||
client.getrange(key, startOffset, endOffset);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<String> getSet(String key, String value) {
|
||||
client.getSet(key, value);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Long> hdel(String key, String field) {
|
||||
client.hdel(key, field);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Boolean> hexists(String key, String field) {
|
||||
client.hexists(key, field);
|
||||
return getResponse(BuilderFactory.BOOLEAN);
|
||||
}
|
||||
|
||||
public Response<String> hget(String key, String field) {
|
||||
client.hget(key, field);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Map<String, String>> hgetAll(String key) {
|
||||
client.hgetAll(key);
|
||||
return getResponse(BuilderFactory.STRING_MAP);
|
||||
}
|
||||
|
||||
public Response<Long> hincrBy(String key, String field, long value) {
|
||||
client.hincrBy(key, field, value);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Set<String>> hkeys(String key) {
|
||||
client.hkeys(key);
|
||||
return getResponse(BuilderFactory.STRING_SET);
|
||||
}
|
||||
|
||||
public Response<Long> hlen(String key) {
|
||||
client.hlen(key);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<List<String>> hmget(String key, String... fields) {
|
||||
client.hmget(key, fields);
|
||||
return getResponse(BuilderFactory.STRING_LIST);
|
||||
}
|
||||
|
||||
public Response<String> hmset(String key, Map<String, String> hash) {
|
||||
client.hmset(key, hash);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Long> hset(String key, String field, String value) {
|
||||
client.hset(key, field, value);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> hsetnx(String key, String field, String value) {
|
||||
client.hsetnx(key, field, value);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<List<String>> hvals(String key) {
|
||||
client.hvals(key);
|
||||
return getResponse(BuilderFactory.STRING_LIST);
|
||||
}
|
||||
|
||||
public Response<Long> incr(String key) {
|
||||
client.incr(key);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> incrBy(String key, long integer) {
|
||||
client.incrBy(key, integer);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Set<String>> keys(String pattern) {
|
||||
client.keys(pattern);
|
||||
return getResponse(BuilderFactory.STRING_SET);
|
||||
}
|
||||
|
||||
public Response<String> lindex(String key, int index) {
|
||||
client.lindex(key, index);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Long> linsert(String key, LIST_POSITION where,
|
||||
String pivot, String value) {
|
||||
client.linsert(key, where, pivot, value);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> llen(String key) {
|
||||
client.llen(key);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<String> lpop(String key) {
|
||||
client.lpop(key);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Long> lpush(String key, String string) {
|
||||
client.lpush(key, string);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> lpushx(String key, String string) {
|
||||
client.lpushx(key, string);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<List<String>> lrange(String key, long start, long end) {
|
||||
client.lrange(key, start, end);
|
||||
return getResponse(BuilderFactory.STRING_LIST);
|
||||
}
|
||||
|
||||
public Response<Long> lrem(String key, long count, String value) {
|
||||
client.lrem(key, count, value);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<String> lset(String key, long index, String value) {
|
||||
client.lset(key, index, value);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<String> ltrim(String key, long start, long end) {
|
||||
client.ltrim(key, start, end);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<List<String>> mget(String... keys) {
|
||||
client.mget(keys);
|
||||
return getResponse(BuilderFactory.STRING_LIST);
|
||||
}
|
||||
|
||||
public Response<Long> move(String key, int dbIndex) {
|
||||
client.move(key, dbIndex);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<String> mset(String... keysvalues) {
|
||||
client.mset(keysvalues);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Long> msetnx(String... keysvalues) {
|
||||
client.msetnx(keysvalues);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> persist(String key) {
|
||||
client.persist(key);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<String> rename(String oldkey, String newkey) {
|
||||
client.rename(oldkey, newkey);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Long> renamenx(String oldkey, String newkey) {
|
||||
client.renamenx(oldkey, newkey);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<String> rpop(String key) {
|
||||
client.rpop(key);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<String> rpoplpush(String srckey, String dstkey) {
|
||||
client.rpoplpush(srckey, dstkey);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Long> rpush(String key, String string) {
|
||||
client.rpush(key, string);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> rpushx(String key, String string) {
|
||||
client.rpushx(key, string);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> sadd(String key, String member) {
|
||||
client.sadd(key, member);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> scard(String key) {
|
||||
client.scard(key);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Set<String>> sdiff(String... keys) {
|
||||
client.sdiff(keys);
|
||||
return getResponse(BuilderFactory.STRING_SET);
|
||||
}
|
||||
|
||||
public Response<Long> sdiffstore(String dstkey, String... keys) {
|
||||
client.sdiffstore(dstkey, keys);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<String> set(String key, String value) {
|
||||
client.set(key, value);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Boolean> setbit(String key, long offset, boolean value) {
|
||||
client.setbit(key, offset, value);
|
||||
return getResponse(BuilderFactory.BOOLEAN);
|
||||
}
|
||||
|
||||
public Response<String> setex(String key, int seconds, String value) {
|
||||
client.setex(key, seconds, value);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Long> setnx(String key, String value) {
|
||||
client.setnx(key, value);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> setrange(String key, long offset, String value) {
|
||||
client.setrange(key, offset, value);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Set<String>> sinter(String... keys) {
|
||||
client.sinter(keys);
|
||||
return getResponse(BuilderFactory.STRING_SET);
|
||||
}
|
||||
|
||||
public Response<Long> sinterstore(String dstkey, String... keys) {
|
||||
client.sinterstore(dstkey, keys);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Boolean> sismember(String key, String member) {
|
||||
client.sismember(key, member);
|
||||
return getResponse(BuilderFactory.BOOLEAN);
|
||||
}
|
||||
|
||||
public Response<Set<String>> smembers(String key) {
|
||||
client.smembers(key);
|
||||
return getResponse(BuilderFactory.STRING_SET);
|
||||
}
|
||||
|
||||
public Response<Long> smove(String srckey, String dstkey, String member) {
|
||||
client.smove(srckey, dstkey, member);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<List<String>> sort(String key) {
|
||||
client.sort(key);
|
||||
return getResponse(BuilderFactory.STRING_LIST);
|
||||
}
|
||||
|
||||
public Response<List<String>> sort(String key,
|
||||
SortingParams sortingParameters) {
|
||||
client.sort(key, sortingParameters);
|
||||
return getResponse(BuilderFactory.STRING_LIST);
|
||||
}
|
||||
|
||||
public Response<List<String>> sort(String key,
|
||||
SortingParams sortingParameters, String dstkey) {
|
||||
client.sort(key, sortingParameters, dstkey);
|
||||
return getResponse(BuilderFactory.STRING_LIST);
|
||||
}
|
||||
|
||||
public Response<List<String>> sort(String key, String dstkey) {
|
||||
client.sort(key, dstkey);
|
||||
return getResponse(BuilderFactory.STRING_LIST);
|
||||
}
|
||||
|
||||
public Response<String> spop(String key) {
|
||||
client.spop(key);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<String> srandmember(String key) {
|
||||
client.srandmember(key);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Long> srem(String key, String member) {
|
||||
client.srem(key, member);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> strlen(String key) {
|
||||
client.strlen(key);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<String> substr(String key, int start, int end) {
|
||||
client.substr(key, start, end);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Set<String>> sunion(String... keys) {
|
||||
client.sunion(keys);
|
||||
return getResponse(BuilderFactory.STRING_SET);
|
||||
}
|
||||
|
||||
public Response<Long> sunionstore(String dstkey, String... keys) {
|
||||
client.sunionstore(dstkey, keys);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> ttl(String key) {
|
||||
client.ttl(key);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<String> type(String key) {
|
||||
client.type(key);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Long> zadd(String key, double score, String member) {
|
||||
client.zadd(key, score, member);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> zcard(String key) {
|
||||
client.zcard(key);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> zcount(String key, double min, double max) {
|
||||
client.zcount(key, min, max);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Double> zincrby(String key, double score, String member) {
|
||||
client.zincrby(key, score, member);
|
||||
return getResponse(BuilderFactory.DOUBLE);
|
||||
}
|
||||
|
||||
public Response<Long> zinterstore(String dstkey, String... sets) {
|
||||
client.zinterstore(dstkey, sets);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> zinterstore(String dstkey, ZParams params,
|
||||
String... sets) {
|
||||
client.zinterstore(dstkey, params, sets);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Set<String>> zrange(String key, int start, int end) {
|
||||
client.zrange(key, start, end);
|
||||
return getResponse(BuilderFactory.STRING_ZSET);
|
||||
}
|
||||
|
||||
public Response<Set<String>> zrangeByScore(String key, double min,
|
||||
double max) {
|
||||
client.zrangeByScore(key, min, max);
|
||||
return getResponse(BuilderFactory.STRING_ZSET);
|
||||
}
|
||||
|
||||
public Response<Set<String>> zrangeByScore(String key, String min,
|
||||
String max) {
|
||||
client.zrangeByScore(key, min, max);
|
||||
return getResponse(BuilderFactory.STRING_ZSET);
|
||||
}
|
||||
|
||||
public Response<Set<String>> zrangeByScore(String key, double min,
|
||||
double max, int offset, int count) {
|
||||
client.zrangeByScore(key, min, max, offset, count);
|
||||
return getResponse(BuilderFactory.STRING_ZSET);
|
||||
}
|
||||
|
||||
public Response<Set<Tuple>> zrangeByScoreWithScores(String key, double min,
|
||||
double max) {
|
||||
client.zrangeByScoreWithScores(key, min, max);
|
||||
return getResponse(BuilderFactory.TUPLE_ZSET);
|
||||
}
|
||||
|
||||
public Response<Set<Tuple>> zrangeByScoreWithScores(String key, double min,
|
||||
double max, int offset, int count) {
|
||||
client.zrangeByScoreWithScores(key, min, max, offset, count);
|
||||
return getResponse(BuilderFactory.TUPLE_ZSET);
|
||||
}
|
||||
|
||||
public Response<Set<Tuple>> zrangeWithScores(String key, int start, int end) {
|
||||
client.zrangeWithScores(key, start, end);
|
||||
return getResponse(BuilderFactory.TUPLE_ZSET);
|
||||
}
|
||||
|
||||
public Response<Long> zrank(String key, String member) {
|
||||
client.zrank(key, member);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> zrem(String key, String member) {
|
||||
client.zrem(key, member);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> zremrangeByRank(String key, int start, int end) {
|
||||
client.zremrangeByRank(key, start, end);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> zremrangeByScore(String key, double start, double end) {
|
||||
client.zremrangeByScore(key, start, end);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Set<String>> zrevrange(String key, int start, int end) {
|
||||
client.zrevrange(key, start, end);
|
||||
return getResponse(BuilderFactory.STRING_ZSET);
|
||||
}
|
||||
|
||||
public Response<Set<Tuple>> zrevrangeWithScores(String key, int start,
|
||||
int end) {
|
||||
client.zrevrangeWithScores(key, start, end);
|
||||
return getResponse(BuilderFactory.TUPLE_ZSET);
|
||||
}
|
||||
|
||||
public Response<Long> zrevrank(String key, String member) {
|
||||
client.zrevrank(key, member);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Double> zscore(String key, String member) {
|
||||
client.zscore(key, member);
|
||||
return getResponse(BuilderFactory.DOUBLE);
|
||||
}
|
||||
|
||||
public Response<Long> zunionstore(String dstkey, String... sets) {
|
||||
client.zunionstore(dstkey, sets);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> zunionstore(String dstkey, ZParams params,
|
||||
String... sets) {
|
||||
client.zunionstore(dstkey, params, sets);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<String> bgrewriteaof() {
|
||||
client.bgrewriteaof();
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<String> bgsave() {
|
||||
client.bgsave();
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<String> configGet(String pattern) {
|
||||
client.configGet(pattern);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<String> configSet(String parameter, String value) {
|
||||
client.configSet(parameter, value);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<String> brpoplpush(String source, String destination,
|
||||
int timeout) {
|
||||
client.brpoplpush(source, destination, timeout);
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<String> configResetStat() {
|
||||
client.configResetStat();
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<String> save() {
|
||||
client.save();
|
||||
return getResponse(BuilderFactory.STRING);
|
||||
}
|
||||
|
||||
public Response<Long> lastsave() {
|
||||
client.lastsave();
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> publish(String channel, String message) {
|
||||
client.publish(channel, message);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
}
|
||||
|
||||
public Response<Long> publish(byte[] channel, byte[] message) {
|
||||
client.publish(channel, message);
|
||||
return getResponse(BuilderFactory.LONG);
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Client getClient(String key) {
|
||||
return client;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Client getClient(byte[] key) {
|
||||
return client;
|
||||
}
|
||||
|
||||
public List<Object> exec() {
|
||||
client.exec();
|
||||
client.getAll(1); // Discard all but the last reply
|
||||
|
||||
List<Object> unformatted = client.getObjectMultiBulkReply();
|
||||
if (unformatted == null) {
|
||||
return null;
|
||||
}
|
||||
List<Object> formatted = new ArrayList<Object>();
|
||||
for (Object o : unformatted) {
|
||||
try {
|
||||
formatted.add(generateResponse(o).get());
|
||||
} catch (JedisDataException e) {
|
||||
formatted.add(e);
|
||||
}
|
||||
}
|
||||
return formatted;
|
||||
}
|
||||
|
||||
public List<Response<?>> execGetResponse() {
|
||||
client.exec();
|
||||
client.getAll(1); // Discard all but the last reply
|
||||
|
||||
List<Object> unformatted = client.getObjectMultiBulkReply();
|
||||
if (unformatted == null) {
|
||||
return null;
|
||||
}
|
||||
List<Response<?>> response = new ArrayList<Response<?>>();
|
||||
for (Object o : unformatted) {
|
||||
response.add(generateResponse(o));
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
public String discard() {
|
||||
client.discard();
|
||||
client.getAll(1); // Discard all but the last reply
|
||||
inTransaction = false;
|
||||
clean();
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,6 +13,6 @@ public abstract class TransactionBlock extends Transaction {
|
||||
public abstract void execute() throws JedisException;
|
||||
|
||||
public void setClient(Client client) {
|
||||
this.client = client;
|
||||
this.client = client;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public class JedisByteHashMap implements Map<byte[], byte[]>, Cloneable,
|
||||
return internalMap.values();
|
||||
}
|
||||
|
||||
private final class ByteArrayWrapper {
|
||||
private static final class ByteArrayWrapper {
|
||||
private final byte[] data;
|
||||
|
||||
public ByteArrayWrapper(byte[] data) {
|
||||
@@ -110,7 +110,7 @@ public class JedisByteHashMap implements Map<byte[], byte[]>, Cloneable,
|
||||
}
|
||||
}
|
||||
|
||||
private final class JedisByteEntry implements Entry<byte[], byte[]> {
|
||||
private static final class JedisByteEntry implements Entry<byte[], byte[]> {
|
||||
private byte[] value;
|
||||
private byte[] key;
|
||||
|
||||
|
||||
@@ -7,8 +7,12 @@ import redis.clients.jedis.exceptions.JedisConnectionException;
|
||||
import redis.clients.jedis.exceptions.JedisException;
|
||||
|
||||
public abstract class Pool<T> {
|
||||
private final GenericObjectPool internalPool;
|
||||
protected GenericObjectPool internalPool;
|
||||
|
||||
protected Pool() {
|
||||
this.internalPool = null;
|
||||
}
|
||||
|
||||
public Pool(final GenericObjectPool.Config poolConfig,
|
||||
PoolableObjectFactory factory) {
|
||||
this.internalPool = new GenericObjectPool(factory, poolConfig);
|
||||
@@ -23,8 +27,8 @@ public abstract class Pool<T> {
|
||||
"Could not get a resource from the pool", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void returnResource(final T resource) {
|
||||
|
||||
public void returnResourceObject(final Object resource) {
|
||||
try {
|
||||
internalPool.returnObject(resource);
|
||||
} catch (Exception e) {
|
||||
@@ -32,8 +36,16 @@ public abstract class Pool<T> {
|
||||
"Could not return the resource to the pool", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void returnBrokenResource(final T resource) {
|
||||
returnBrokenResourceObject(resource);
|
||||
}
|
||||
|
||||
public void returnResource(final T resource) {
|
||||
returnResourceObject(resource);
|
||||
}
|
||||
|
||||
protected void returnBrokenResourceObject(final Object resource) {
|
||||
try {
|
||||
internalPool.invalidateObject(resource);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import redis.clients.jedis.exceptions.JedisConnectionException;
|
||||
import redis.clients.jedis.exceptions.JedisException;
|
||||
|
||||
public class RedisInputStream extends FilterInputStream {
|
||||
|
||||
@@ -84,7 +83,7 @@ public class RedisInputStream extends FilterInputStream {
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new JedisException(e);
|
||||
throw new JedisConnectionException(e);
|
||||
}
|
||||
String reply = sb.toString();
|
||||
if (reply.length() == 0) {
|
||||
|
||||
@@ -11,6 +11,14 @@ import redis.clients.jedis.exceptions.JedisException;
|
||||
*
|
||||
*/
|
||||
public class SafeEncoder {
|
||||
public static byte[][] encodeMany(final String... strs){
|
||||
byte[][] many = new byte[strs.length][];
|
||||
for(int i=0;i<strs.length;i++){
|
||||
many[i] = encode(strs[i]);
|
||||
}
|
||||
return many;
|
||||
}
|
||||
|
||||
public static byte[] encode(final String str) {
|
||||
try {
|
||||
if (str == null) {
|
||||
|
||||
@@ -77,7 +77,7 @@ public class Sharded<R, S extends ShardInfo<R>> {
|
||||
|
||||
public S getShardInfo(byte[] key) {
|
||||
SortedMap<Long, S> tail = nodes.tailMap(algo.hash(key));
|
||||
if (tail.size() == 0) {
|
||||
if (tail.isEmpty()) {
|
||||
return nodes.get(nodes.firstKey());
|
||||
}
|
||||
return tail.get(tail.firstKey());
|
||||
|
||||
53
src/main/java/redis/clients/util/Slowlog.java
Normal file
53
src/main/java/redis/clients/util/Slowlog.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package redis.clients.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Slowlog {
|
||||
private final long id;
|
||||
private final long timeStamp;
|
||||
private final long executionTime;
|
||||
private final List<String> args;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<Slowlog> from(List<Object> nestedMultiBulkReply){
|
||||
List<Slowlog> logs = new ArrayList<Slowlog>(nestedMultiBulkReply.size());
|
||||
for(Object obj : nestedMultiBulkReply){
|
||||
List<Object> properties = (List<Object>)obj;
|
||||
logs.add(new Slowlog(properties));
|
||||
}
|
||||
|
||||
return logs;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Slowlog(List<Object> properties) {
|
||||
super();
|
||||
this.id = (Long)properties.get(0);
|
||||
this.timeStamp = (Long)properties.get(1);
|
||||
this.executionTime = (Long)properties.get(2);
|
||||
|
||||
List<byte[]> bargs = (List<byte[]>)properties.get(3);
|
||||
this.args = new ArrayList<String>(bargs.size());
|
||||
|
||||
for(byte[] barg:bargs){
|
||||
this.args.add(SafeEncoder.encode(barg));
|
||||
}
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public long getTimeStamp() {
|
||||
return timeStamp;
|
||||
}
|
||||
|
||||
public long getExecutionTime() {
|
||||
return executionTime;
|
||||
}
|
||||
|
||||
public List<String> getArgs() {
|
||||
return args;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user