Merge branch 'master' of github.com:rdifalco/jedis into rdifalco-master

Conflicts:
	src/main/java/redis/clients/jedis/BinaryJedis.java
This commit is contained in:
Jungtaek Lim
2014-11-13 13:20:59 +09:00
5 changed files with 197 additions and 226 deletions

View File

@@ -253,9 +253,7 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
public Set<byte[]> keys(final byte[] pattern) {
checkIsInMulti();
client.keys(pattern);
final HashSet<byte[]> keySet = new HashSet<byte[]>(
client.getBinaryMultiBulkReply());
return keySet;
return new HashSet<byte[]>(client.getBinaryMultiBulkReply());
}
/**
@@ -519,7 +517,7 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
/**
* Set the the respective keys to the respective values. MSET will replace
* old values with new values, while {@link #msetnx(String...) MSETNX} will
* old values with new values, while {@link #msetnx(byte[]...) MSETNX} will
* not perform any operation at all even if just a single key already
* exists.
* <p>
@@ -532,7 +530,7 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
* either see the changes to both A and B at once, or no modification at
* all.
*
* @see #msetnx(String...)
* @see #msetnx(byte[]...)
*
* @param keysvalues
* @return Status code reply Basically +OK as MSET can't fail
@@ -545,7 +543,7 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
/**
* Set the the respective keys to the respective values.
* {@link #mset(String...) MSET} will replace old values with new values,
* {@link #mset(byte[]...) MSET} will replace old values with new values,
* while MSETNX will not perform any operation at all even if just a single
* key already exists.
* <p>
@@ -558,8 +556,8 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
* either see the changes to both A and B at once, or no modification at
* all.
*
* @see #mset(String...)
*
* @see #mset(byte[]...)
*
* @param keysvalues
* @return Integer reply, specifically: 1 if the all the keys were set 0 if
* no key was set (at least one key already existed)
@@ -571,7 +569,7 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
}
/**
* IDECRBY work just like {@link #decr(String) INCR} but instead to
* DECRBY work just like {@link #decr(byte[]) INCR} but instead to
* decrement by 1 the decrement is integer.
* <p>
* INCR commands are limited to 64 bit signed integers.
@@ -655,7 +653,7 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
}
/**
* INCRBYFLOAT work just like {@link #incrBy(byte[]) INCRBY} but increments
* INCRBYFLOAT work just like {@link #incrBy(byte[], long)} INCRBY} but increments
* by floats instead of integers.
* <p>
* INCRBYFLOAT commands are limited to double precision floating point
@@ -673,8 +671,8 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
* @see #decr(byte[])
* @see #decrBy(byte[], long)
*
* @param key
* @param integer
* @param key the key to increment
* @param integer the value to increment by
* @return Integer reply, this commands will reply with the new value of key
* after the increment.
*/
@@ -978,8 +976,7 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
public List<byte[]> hvals(final byte[] key) {
checkIsInMulti();
client.hvals(key);
final List<byte[]> lresult = client.getBinaryMultiBulkReply();
return lresult;
return client.getBinaryMultiBulkReply();
}
/**
@@ -1184,7 +1181,7 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
* O(N) (with N being the length of the list), setting the first or last
* elements of the list is O(1).
*
* @see #lindex(byte[], int)
* @see #lindex(byte[], long)
*
* @param key
* @param index
@@ -1305,11 +1302,11 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
/**
* Return all the members (elements) of the set value stored at key. This is
* just syntax glue for {@link #sinter(String...) SINTER}.
* just syntax glue for {@link #sinter(byte[]...)} SINTER}.
* <p>
* Time complexity O(N)
*
* @param key
* @param key the key of the set
* @return Multi bulk reply
*/
public Set<byte[]> smembers(final byte[] key) {
@@ -1326,8 +1323,8 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
* <p>
* Time complexity O(1)
*
* @param key
* @param member
* @param key the key of the set
* @param member the set member to remove
* @return Integer reply, specifically: 1 if the new element was removed 0
* if the new element was not a member of the set
*/
@@ -1420,7 +1417,7 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
/**
* Return the members of a set resulting from the intersection of all the
* sets hold at the specified keys. Like in
* {@link #lrange(byte[], int, int) LRANGE} the result is sent to the client
* {@link #lrange(byte[], long, long)} LRANGE} the result is sent to the client
* as a multi-bulk reply (see the protocol specification for more
* information). If just a single key is specified, then this command
* produces the same result as {@link #smembers(byte[]) SMEMBERS}. Actually
@@ -1444,7 +1441,7 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
}
/**
* This commnad works exactly like {@link #sinter(String...) SINTER} but
* This commnad works exactly like {@link #sinter(byte[]...) SINTER} but
* instead of being returned the resulting set is sotred as dstkey.
* <p>
* Time complexity O(N*M) worst case where N is the cardinality of the
@@ -1462,7 +1459,7 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
/**
* Return the members of a set resulting from the union of all the sets hold
* at the specified keys. Like in {@link #lrange(byte[], int, int) LRANGE}
* at the specified keys. Like in {@link #lrange(byte[], long, long)} LRANGE}
* the result is sent to the client as a multi-bulk reply (see the protocol
* specification for more information). If just a single key is specified,
* then this command produces the same result as {@link #smembers(byte[])
@@ -1484,7 +1481,7 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
}
/**
* This command works exactly like {@link #sunion(String...) SUNION} but
* This command works exactly like {@link #sunion(byte[]...) SUNION} but
* instead of being returned the resulting set is stored as dstkey. Any
* existing value in dstkey will be over-written.
* <p>
@@ -1532,7 +1529,7 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
}
/**
* This command works exactly like {@link #sdiff(String...) SDIFF} but
* This command works exactly like {@link #sdiff(byte[]...) SDIFF} but
* instead of being returned the resulting set is stored in dstkey.
*
* @param dstkey
@@ -1726,16 +1723,14 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
final long end) {
checkIsInMulti();
client.zrangeWithScores(key, start, end);
Set<Tuple> set = getBinaryTupledSet();
return set;
return getBinaryTupledSet();
}
public Set<Tuple> zrevrangeWithScores(final byte[] key, final long start,
final long end) {
checkIsInMulti();
client.zrevrangeWithScores(key, start, end);
Set<Tuple> set = getBinaryTupledSet();
return set;
return getBinaryTupledSet();
}
/**
@@ -1995,7 +1990,7 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
* <p>
* Time complexity: O(1)
*
* @see #brpop(int, String...)
* @see #brpop(int, byte[]...)
*
* @param timeout
* @param keys
@@ -2008,18 +2003,17 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
* programming language used.
*/
public List<byte[]> blpop(final int timeout, final byte[]... keys) {
checkIsInMulti();
final List<byte[]> args = new ArrayList<byte[]>();
for (final byte[] arg : keys) {
args.add(arg);
}
args.add(Protocol.toByteArray(timeout));
return blpop(getArgsAddTimeout(timeout, keys));
}
client.blpop(args.toArray(new byte[args.size()][]));
client.setTimeoutInfinite();
final List<byte[]> multiBulkReply = client.getBinaryMultiBulkReply();
client.rollbackTimeout();
return multiBulkReply;
private byte[][] getArgsAddTimeout (int timeout, byte[][] keys) {
int size = keys.length;
final byte[][] args = new byte[size + 1][];
for (int at = 0; at != size; ++at) {
args[at] = keys[at];
}
args[size] = Protocol.toByteArray(timeout);
return args;
}
/**
@@ -2124,7 +2118,7 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
* <p>
* Time complexity: O(1)
*
* @see #blpop(int, String...)
* @see #blpop(int, byte[]...)
*
* @param timeout
* @param keys
@@ -2137,59 +2131,46 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
* programming language used.
*/
public List<byte[]> brpop(final int timeout, final byte[]... keys) {
checkIsInMulti();
final List<byte[]> args = new ArrayList<byte[]>();
for (final byte[] arg : keys) {
args.add(arg);
}
args.add(Protocol.toByteArray(timeout));
client.brpop(args.toArray(new byte[args.size()][]));
client.setTimeoutInfinite();
final List<byte[]> multiBulkReply = client.getBinaryMultiBulkReply();
client.rollbackTimeout();
return multiBulkReply;
return brpop(getArgsAddTimeout(timeout, keys));
}
/**
* @deprecated unusable command, this command will be removed in 3.0.0.
*/
@Deprecated
public List<byte[]> blpop(byte[] arg) {
checkIsInMulti();
byte[][] args = new byte[1][];
args[0] = arg;
client.blpop(args);
client.setTimeoutInfinite();
final List<byte[]> multiBulkReply = client.getBinaryMultiBulkReply();
client.rollbackTimeout();
return multiBulkReply;
return blpop(new byte[][]{arg});
}
/**
* @deprecated unusable command, this command will be removed in 3.0.0.
*/
@Deprecated
public List<byte[]> brpop(byte[] arg) {
checkIsInMulti();
byte[][] args = new byte[1][];
args[0] = arg;
client.brpop(args);
client.setTimeoutInfinite();
final List<byte[]> multiBulkReply = client.getBinaryMultiBulkReply();
client.rollbackTimeout();
return multiBulkReply;
return brpop(new byte[][]{arg});
}
public List<byte[]> blpop(byte[]... args) {
checkIsInMulti();
client.blpop(args);
client.setTimeoutInfinite();
final List<byte[]> multiBulkReply = client.getBinaryMultiBulkReply();
client.rollbackTimeout();
return multiBulkReply;
try {
return client.getBinaryMultiBulkReply();
} finally {
client.rollbackTimeout();
}
}
public List<byte[]> brpop(byte[]... args) {
checkIsInMulti();
client.brpop(args);
client.setTimeoutInfinite();
final List<byte[]> multiBulkReply = client.getBinaryMultiBulkReply();
client.rollbackTimeout();
return multiBulkReply;
try {
return client.getBinaryMultiBulkReply();
} finally {
client.rollbackTimeout();
}
}
/**
@@ -2431,8 +2412,7 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
final byte[] min, final byte[] max) {
checkIsInMulti();
client.zrangeByScoreWithScores(key, min, max);
Set<Tuple> set = getBinaryTupledSet();
return set;
return getBinaryTupledSet();
}
/**
@@ -2503,8 +2483,7 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
final int count) {
checkIsInMulti();
client.zrangeByScoreWithScores(key, min, max, offset, count);
Set<Tuple> set = getBinaryTupledSet();
return set;
return getBinaryTupledSet();
}
private Set<Tuple> getBinaryTupledSet() {
@@ -2561,8 +2540,7 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
final byte[] max, final byte[] min) {
checkIsInMulti();
client.zrevrangeByScoreWithScores(key, max, min);
Set<Tuple> set = getBinaryTupledSet();
return set;
return getBinaryTupledSet();
}
public Set<Tuple> zrevrangeByScoreWithScores(final byte[] key,
@@ -2570,8 +2548,7 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
final int count) {
checkIsInMulti();
client.zrevrangeByScoreWithScores(key, max, min, offset, count);
Set<Tuple> set = getBinaryTupledSet();
return set;
return getBinaryTupledSet();
}
/**
@@ -2626,10 +2603,10 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
* input keys N, before passing the input keys and the other (optional)
* arguments.
* <p>
* As the terms imply, the {@link #zinterstore(String, String...)
* As the terms imply, the {@link #zinterstore(byte[], byte[]...)}
* ZINTERSTORE} command requires an element to be present in each of the
* given inputs to be inserted in the result. The
* {@link #zunionstore(String, String...) ZUNIONSTORE} command inserts all
* {@link #zunionstore(byte[], byte[]...)}} command inserts all
* elements across all inputs.
* <p>
* Using the WEIGHTS option, it is possible to add weight to each input
@@ -2648,10 +2625,10 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
* sizes of the input sorted sets, and M being the number of elements in the
* resulting sorted set
*
* @see #zunionstore(String, String...)
* @see #zunionstore(String, ZParams, String...)
* @see #zinterstore(String, String...)
* @see #zinterstore(String, ZParams, String...)
* @see #zunionstore(byte[], byte[]...)
* @see #zunionstore(byte[], ZParams, byte[]...)
* @see #zinterstore(byte[], byte[]...)
* @see #zinterstore(byte[], ZParams, byte[]...)
*
* @param dstkey
* @param sets
@@ -2670,10 +2647,10 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
* input keys N, before passing the input keys and the other (optional)
* arguments.
* <p>
* As the terms imply, the {@link #zinterstore(String, String...)
* As the terms imply, the {@link #zinterstore(byte[], byte[]...)
* ZINTERSTORE} command requires an element to be present in each of the
* given inputs to be inserted in the result. The
* {@link #zunionstore(String, String...) ZUNIONSTORE} command inserts all
* {@link #zunionstore(byte[], byte[]...) ZUNIONSTORE} command inserts all
* elements across all inputs.
* <p>
* Using the WEIGHTS option, it is possible to add weight to each input
@@ -2692,10 +2669,10 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
* sizes of the input sorted sets, and M being the number of elements in the
* resulting sorted set
*
* @see #zunionstore(String, String...)
* @see #zunionstore(String, ZParams, String...)
* @see #zinterstore(String, String...)
* @see #zinterstore(String, ZParams, String...)
* @see #zunionstore(byte[], byte[]...)
* @see #zunionstore(byte[], ZParams, byte[]...)
* @see #zinterstore(byte[], byte[]...)
* @see #zinterstore(byte[], ZParams, byte[]...)
*
* @param dstkey
* @param sets
@@ -2716,10 +2693,10 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
* input keys N, before passing the input keys and the other (optional)
* arguments.
* <p>
* As the terms imply, the {@link #zinterstore(String, String...)
* As the terms imply, the {@link #zinterstore(byte[], byte[]...)
* ZINTERSTORE} command requires an element to be present in each of the
* given inputs to be inserted in the result. The
* {@link #zunionstore(String, String...) ZUNIONSTORE} command inserts all
* {@link #zunionstore(byte[], byte[]...) ZUNIONSTORE} command inserts all
* elements across all inputs.
* <p>
* Using the WEIGHTS option, it is possible to add weight to each input
@@ -2738,10 +2715,10 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
* sizes of the input sorted sets, and M being the number of elements in the
* resulting sorted set
*
* @see #zunionstore(String, String...)
* @see #zunionstore(String, ZParams, String...)
* @see #zinterstore(String, String...)
* @see #zinterstore(String, ZParams, String...)
* @see #zunionstore(byte[], byte[]...)
* @see #zunionstore(byte[], ZParams, byte[]...)
* @see #zinterstore(byte[], byte[]...)
* @see #zinterstore(byte[], ZParams, byte[]...)
*
* @param dstkey
* @param sets
@@ -2760,10 +2737,10 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
* input keys N, before passing the input keys and the other (optional)
* arguments.
* <p>
* As the terms imply, the {@link #zinterstore(String, String...)
* As the terms imply, the {@link #zinterstore(byte[], byte[]...)
* ZINTERSTORE} command requires an element to be present in each of the
* given inputs to be inserted in the result. The
* {@link #zunionstore(String, String...) ZUNIONSTORE} command inserts all
* {@link #zunionstore(byte[], byte[]...) ZUNIONSTORE} command inserts all
* elements across all inputs.
* <p>
* Using the WEIGHTS option, it is possible to add weight to each input
@@ -2782,10 +2759,10 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
* sizes of the input sorted sets, and M being the number of elements in the
* resulting sorted set
*
* @see #zunionstore(String, String...)
* @see #zunionstore(String, ZParams, String...)
* @see #zinterstore(String, String...)
* @see #zinterstore(String, ZParams, String...)
* @see #zunionstore(byte[], byte[]...)
* @see #zunionstore(byte[], ZParams, byte[]...)
* @see #zinterstore(byte[], byte[]...)
* @see #zinterstore(byte[], ZParams, byte[]...)
*
* @param dstkey
* @param sets
@@ -2935,7 +2912,7 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
*/
public String shutdown() {
client.shutdown();
String status = null;
String status;
try {
status = client.getStatusCodeReply();
} catch (JedisException ex) {
@@ -3101,7 +3078,7 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
* configuration parameters are supported.
* <p>
* The list of configuration parameters supported by CONFIG SET can be
* obtained issuing a {@link #configGet(String) CONFIG GET *} command.
* obtained issuing a {@link #configGet(byte[]) CONFIG GET *} command.
* <p>
* The configuration set using CONFIG SET is immediately loaded by the Redis
* server that will start acting as specified starting from the next
@@ -3205,9 +3182,11 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
public byte[] brpoplpush(byte[] source, byte[] destination, int timeout) {
client.brpoplpush(source, destination, timeout);
client.setTimeoutInfinite();
byte[] reply = client.getBinaryBulkReply();
client.rollbackTimeout();
return reply;
try {
return client.getBinaryBulkReply();
} finally {
client.rollbackTimeout();
}
}
/**
@@ -3267,14 +3246,20 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
public void subscribe(BinaryJedisPubSub jedisPubSub, byte[]... channels) {
client.setTimeoutInfinite();
jedisPubSub.proceed(client, channels);
client.rollbackTimeout();
try {
jedisPubSub.proceed(client, channels);
} finally {
client.rollbackTimeout();
}
}
public void psubscribe(BinaryJedisPubSub jedisPubSub, byte[]... patterns) {
client.setTimeoutInfinite();
jedisPubSub.proceedWithPatterns(client, patterns);
client.rollbackTimeout();
try {
jedisPubSub.proceedWithPatterns(client, patterns);
} finally {
client.rollbackTimeout();
}
}
public Long getDB() {
@@ -3289,15 +3274,13 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
* @return Script result
*/
public Object eval(byte[] script, List<byte[]> keys, List<byte[]> args) {
client.setTimeoutInfinite();
client.eval(script, toByteArray(keys.size()), getParams(keys, args));
return client.getOne();
return eval(script, toByteArray(keys.size()), getParams(keys, args));
}
private byte[][] getParams(List<byte[]> keys, List<byte[]> args) {
int keyCount = keys.size();
int argCount = args.size();
byte[][] params = new byte[keyCount + args.size()][];
final int keyCount = keys.size();
final int argCount = args.size();
byte[][] params = new byte[keyCount + argCount][];
for (int i = 0; i < keyCount; i++)
params[i] = keys.get(i);
@@ -3310,49 +3293,38 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
public Object eval(byte[] script, byte[] keyCount, byte[]... params) {
client.setTimeoutInfinite();
client.eval(script, keyCount, params);
return client.getOne();
try {
client.eval(script, keyCount, params);
return client.getOne();
} finally {
client.rollbackTimeout();
}
}
public Object eval(byte[] script, int keyCount, byte[]... params) {
client.setTimeoutInfinite();
client.eval(script, SafeEncoder.encode(Integer.toString(keyCount)),
params);
return client.getOne();
return eval(script, toByteArray(keyCount), params);
}
public Object eval(byte[] script) {
client.setTimeoutInfinite();
client.eval(script, 0);
return client.getOne();
return eval(script, 0);
}
public Object evalsha(byte[] sha1) {
client.setTimeoutInfinite();
client.evalsha(sha1, 0);
return client.getOne();
return evalsha(sha1, 1);
}
public Object evalsha(byte[] sha1, List<byte[]> keys, List<byte[]> args) {
int keyCount = keys == null ? 0 : keys.size();
int argCount = args == null ? 0 : args.size();
byte[][] params = new byte[keyCount + argCount][];
for (int i = 0; i < keyCount; i++)
params[i] = keys.get(i);
for (int i = 0; i < argCount; i++)
params[keyCount + i] = args.get(i);
return evalsha(sha1, keyCount, params);
return evalsha(sha1, keys.size(), getParams(keys, args));
}
public Object evalsha(byte[] sha1, int keyCount, byte[]... params) {
client.setTimeoutInfinite();
client.evalsha(sha1, keyCount, params);
return client.getOne();
try {
client.evalsha(sha1, keyCount, params);
return client.getOne();
} finally {
client.rollbackTimeout();
}
}
public String scriptFlush() {

View File

@@ -219,8 +219,18 @@ public interface BinaryJedisCommands {
Long rpushx(byte[] key, byte[]... arg);
/**
* @deprecated unusable command, this command will be removed in 3.0.0.
*/
@Deprecated
List<byte[]> blpop(byte[] arg);
/**
* @deprecated unusable command, this command will be removed in 3.0.0.
*/
@Deprecated
List<byte[]> brpop(byte[] arg);
Long del(byte[] key);

View File

@@ -54,7 +54,6 @@ public class Connection implements Closeable {
if (!isConnected()) {
connect();
}
socket.setKeepAlive(true);
socket.setSoTimeout(0);
} catch (SocketException ex) {
broken = true;
@@ -65,7 +64,6 @@ public class Connection implements Closeable {
public void rollbackTimeout() {
try {
socket.setSoTimeout(timeout);
socket.setKeepAlive(false);
} catch (SocketException ex) {
broken = true;
throw new JedisConnectionException(ex);

View File

@@ -1849,54 +1849,56 @@ public class Jedis extends BinaryJedis implements JedisCommands,
* programming language used.
*/
public List<String> blpop(final int timeout, final String... keys) {
checkIsInMulti();
List<String> args = new ArrayList<String>();
for (String arg : keys) {
args.add(arg);
}
args.add(String.valueOf(timeout));
return blpop(getArgsAddTimeout(timeout, keys));
}
client.blpop(args.toArray(new String[args.size()]));
client.setTimeoutInfinite();
final List<String> multiBulkReply = client.getMultiBulkReply();
client.rollbackTimeout();
return multiBulkReply;
private String[] getArgsAddTimeout (int timeout, String[] keys) {
final int keyCount = keys.length;
final String[] args = new String[keyCount + 1];
for (int at = 0; at != keyCount; ++at) {
args[at] = keys[at];
}
args[keyCount] = String.valueOf(timeout);
return args;
}
public List<String> blpop(String... args) {
checkIsInMulti();
client.blpop(args);
client.setTimeoutInfinite();
final List<String> multiBulkReply = client.getMultiBulkReply();
client.rollbackTimeout();
return multiBulkReply;
try {
return client.getMultiBulkReply();
} finally {
client.rollbackTimeout();
}
}
public List<String> brpop(String... args) {
checkIsInMulti();
client.brpop(args);
client.setTimeoutInfinite();
final List<String> multiBulkReply = client.getMultiBulkReply();
client.rollbackTimeout();
return multiBulkReply;
try {
return client.getMultiBulkReply();
} finally {
client.rollbackTimeout();
}
}
/**
* @deprecated unusable command, this command will be removed in 3.0.0.
*/
@Deprecated
public List<String> blpop(String arg) {
String[] args = new String[1];
args[0] = arg;
client.blpop(args);
client.setTimeoutInfinite();
final List<String> multiBulkReply = client.getMultiBulkReply();
client.rollbackTimeout();
return multiBulkReply;
return blpop(new String[]{arg});
}
/**
* @deprecated unusable command, this command will be removed in 3.0.0.
*/
@Deprecated
public List<String> brpop(String arg) {
String[] args = new String[1];
args[0] = arg;
client.brpop(args);
client.setTimeoutInfinite();
final List<String> multiBulkReply = client.getMultiBulkReply();
client.rollbackTimeout();
return multiBulkReply;
return brpop(new String[]{arg});
}
/**
@@ -2014,19 +2016,7 @@ public class Jedis extends BinaryJedis implements JedisCommands,
* programming language used.
*/
public List<String> brpop(final int timeout, final String... keys) {
checkIsInMulti();
List<String> args = new ArrayList<String>();
for (String arg : keys) {
args.add(arg);
}
args.add(String.valueOf(timeout));
client.brpop(args.toArray(new String[args.size()]));
client.setTimeoutInfinite();
List<String> multiBulkReply = client.getMultiBulkReply();
client.rollbackTimeout();
return multiBulkReply;
return brpop(getArgsAddTimeout(timeout, keys));
}
public Long zcount(final String key, final double min, final double max) {
@@ -2730,9 +2720,11 @@ public class Jedis extends BinaryJedis implements JedisCommands,
public String brpoplpush(String source, String destination, int timeout) {
client.brpoplpush(source, destination, timeout);
client.setTimeoutInfinite();
String reply = client.getBulkReply();
client.rollbackTimeout();
return reply;
try {
return client.getBulkReply();
} finally {
client.rollbackTimeout();
}
}
/**
@@ -2867,16 +2859,22 @@ public class Jedis extends BinaryJedis implements JedisCommands,
public Object eval(String script, int keyCount, String... params) {
client.setTimeoutInfinite();
client.eval(script, keyCount, params);
return getEvalResult();
try {
client.eval(script, keyCount, params);
return getEvalResult();
} finally {
client.rollbackTimeout();
}
}
public void subscribe(final JedisPubSub jedisPubSub,
final String... channels) {
client.setTimeoutInfinite();
jedisPubSub.proceed(client, channels);
client.rollbackTimeout();
try {
jedisPubSub.proceed(client, channels);
} finally {
client.rollbackTimeout();
}
}
public Long publish(final String channel, final String message) {
@@ -2889,10 +2887,12 @@ public class Jedis extends BinaryJedis implements JedisCommands,
public void psubscribe(final JedisPubSub jedisPubSub,
final String... patterns) {
checkIsInMulti();
connect();
client.setTimeoutInfinite();
jedisPubSub.proceedWithPatterns(client, patterns);
client.rollbackTimeout();
try {
jedisPubSub.proceedWithPatterns(client, patterns);
} finally {
client.rollbackTimeout();
}
}
protected static String[] getParams(List<String> keys, List<String> args) {
@@ -2950,7 +2950,6 @@ public class Jedis extends BinaryJedis implements JedisCommands,
public Object evalsha(String sha1, int keyCount, String... params) {
checkIsInMulti();
client.evalsha(sha1, keyCount, params);
return getEvalResult();
}
@@ -3509,28 +3508,12 @@ public class Jedis extends BinaryJedis implements JedisCommands,
@Override
public List<String> blpop(int timeout, String key) {
checkIsInMulti();
List<String> args = new ArrayList<String>();
args.add(key);
args.add(String.valueOf(timeout));
client.blpop(args.toArray(new String[args.size()]));
client.setTimeoutInfinite();
final List<String> multiBulkReply = client.getMultiBulkReply();
client.rollbackTimeout();
return multiBulkReply;
return blpop(key, String.valueOf(timeout));
}
@Override
public List<String> brpop(int timeout, String key) {
checkIsInMulti();
List<String> args = new ArrayList<String>();
args.add(key);
args.add(String.valueOf(timeout));
client.brpop(args.toArray(new String[args.size()]));
client.setTimeoutInfinite();
final List<String> multiBulkReply = client.getMultiBulkReply();
client.rollbackTimeout();
return multiBulkReply;
return brpop(key, String.valueOf(timeout));
}
}

View File

@@ -216,10 +216,18 @@ public interface JedisCommands {
Long rpushx(String key, String... string);
/**
* @deprecated unusable command, this will be removed in 3.0.0.
*/
@Deprecated
List<String> blpop(String arg);
List<String> blpop(int timeout, String key);
/**
* @deprecated unusable command, this will be removed in 3.0.0.
*/
@Deprecated
List<String> brpop(String arg);
List<String> brpop(int timeout, String key);