add blpop/brpop with timeout parameter interface to JedisCommands
This commit is contained in:
@@ -3433,4 +3433,31 @@ public class Jedis extends BinaryJedis implements JedisCommands,
|
||||
client.pfmerge(destkey, sourcekeys);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1474,4 +1474,26 @@ public class JedisCluster implements JedisCommands, BasicCommands {
|
||||
}
|
||||
}.run(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> blpop(final int timeout, final String key) {
|
||||
return new JedisClusterCommand<List<String>>(connectionHandler,
|
||||
timeout, maxRedirections) {
|
||||
@Override
|
||||
public List<String> execute(Jedis connection) {
|
||||
return connection.blpop(timeout,key);
|
||||
}
|
||||
}.run(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> brpop(final int timeout, final String key) {
|
||||
return new JedisClusterCommand<List<String>>(connectionHandler,
|
||||
timeout, maxRedirections) {
|
||||
@Override
|
||||
public List<String> execute(Jedis connection) {
|
||||
return connection.brpop(timeout,key);
|
||||
}
|
||||
}.run(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,8 +203,12 @@ public interface JedisCommands {
|
||||
Long rpushx(String key, String... string);
|
||||
|
||||
List<String> blpop(String arg);
|
||||
|
||||
List<String> blpop(int timeout, String key);
|
||||
|
||||
List<String> brpop(String arg);
|
||||
|
||||
List<String> brpop(int timeout, String key);
|
||||
|
||||
Long del(String key);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user