Merge branch 'master' into support-sorted-set-with-lex
Conflicts: src/main/java/redis/clients/jedis/BinaryShardedJedis.java src/main/java/redis/clients/jedis/Jedis.java src/main/java/redis/clients/jedis/Protocol.java src/test/java/redis/clients/jedis/tests/commands/SortedSetCommandsTest.java
This commit is contained in:
@@ -1,15 +1,22 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
import java.io.Closeable;
|
||||
import redis.clients.jedis.BinaryClient.LIST_POSITION;
|
||||
import redis.clients.util.Hashing;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
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.Pool;
|
||||
|
||||
public class ShardedJedis extends BinaryShardedJedis implements JedisCommands,
|
||||
Closeable {
|
||||
|
||||
protected Pool<ShardedJedis> dataSource = null;
|
||||
|
||||
public class ShardedJedis extends BinaryShardedJedis implements JedisCommands {
|
||||
public ShardedJedis(List<JedisShardInfo> shards) {
|
||||
super(shards);
|
||||
}
|
||||
@@ -32,6 +39,13 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands {
|
||||
return j.set(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String set(String key, String value, String nxxx, String expx,
|
||||
long time) {
|
||||
Jedis j = getShard(key);
|
||||
return j.set(key, value, nxxx, expx, time);
|
||||
}
|
||||
|
||||
public String get(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.get(key);
|
||||
@@ -132,6 +146,11 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands {
|
||||
return j.incrBy(key, integer);
|
||||
}
|
||||
|
||||
public Double incrByFloat(String key, double integer) {
|
||||
Jedis j = getShard(key);
|
||||
return j.incrByFloat(key, integer);
|
||||
}
|
||||
|
||||
public Long incr(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.incr(key);
|
||||
@@ -177,6 +196,11 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands {
|
||||
return j.hincrBy(key, field, value);
|
||||
}
|
||||
|
||||
public Double hincrByFloat(String key, String field, double value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hincrByFloat(key, field, value);
|
||||
}
|
||||
|
||||
public Boolean hexists(String key, String field) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hexists(key, field);
|
||||
@@ -322,6 +346,12 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands {
|
||||
return j.srandmember(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> srandmember(String key, int count) {
|
||||
Jedis j = getShard(key);
|
||||
return j.srandmember(key, count);
|
||||
}
|
||||
|
||||
public Long zadd(String key, double score, String member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zadd(key, score, member);
|
||||
@@ -544,52 +574,63 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands {
|
||||
return j.bitcount(key, start, end);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
/**
|
||||
* This method is deprecated due to bug (scan cursor should be unsigned long)
|
||||
* And will be removed on next major release
|
||||
* @see https://github.com/xetorthio/jedis/issues/531
|
||||
*/
|
||||
public ScanResult<Entry<String, String>> hscan(String key, int cursor) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hscan(key, cursor);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
/**
|
||||
* This method is deprecated due to bug (scan cursor should be unsigned long)
|
||||
* And will be removed on next major release
|
||||
* @see https://github.com/xetorthio/jedis/issues/531
|
||||
*/
|
||||
public ScanResult<String> sscan(String key, int cursor) {
|
||||
Jedis j = getShard(key);
|
||||
return j.sscan(key, cursor);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
/**
|
||||
* This method is deprecated due to bug (scan cursor should be unsigned long)
|
||||
* And will be removed on next major release
|
||||
* @see https://github.com/xetorthio/jedis/issues/531
|
||||
*/
|
||||
public ScanResult<Tuple> zscan(String key, int cursor) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zscan(key, cursor);
|
||||
}
|
||||
|
||||
public ScanResult<Entry<String, String>> hscan(String key, final String cursor) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hscan(key, cursor);
|
||||
}
|
||||
|
||||
|
||||
public ScanResult<String> sscan(String key, final String cursor) {
|
||||
Jedis j = getShard(key);
|
||||
return j.sscan(key, cursor);
|
||||
}
|
||||
|
||||
|
||||
public ScanResult<Tuple> zscan(String key, final String cursor) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zscan(key, cursor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
if (dataSource != null) {
|
||||
boolean broken = false;
|
||||
|
||||
for (Jedis jedis : getAllShards()) {
|
||||
if (jedis.getClient().isBroken()) {
|
||||
broken = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (broken) {
|
||||
dataSource.returnBrokenResource(this);
|
||||
} else {
|
||||
this.resetState();
|
||||
dataSource.returnResource(this);
|
||||
}
|
||||
|
||||
} else {
|
||||
disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
public void setDataSource(Pool<ShardedJedis> shardedJedisPool) {
|
||||
this.dataSource = shardedJedisPool;
|
||||
}
|
||||
|
||||
public void resetState() {
|
||||
for (Jedis jedis : getAllShards()) {
|
||||
jedis.resetState();
|
||||
}
|
||||
}
|
||||
|
||||
public Long pfadd(String key, String... elements) {
|
||||
Jedis j = getShard(key);
|
||||
return j.pfadd(key, elements);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long pfcount(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.pfcount(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user