Implemented BLPOP
This commit is contained in:
@@ -395,4 +395,8 @@ public class Client extends Connection {
|
||||
args.addAll(sortingParameters.getParams());
|
||||
sendCommand("SORT", args.toArray(new String[args.size()]));
|
||||
}
|
||||
|
||||
public void blpop(String[] args) throws JedisException {
|
||||
sendCommand("BLPOP", args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package redis.clients.jedis;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
@@ -428,7 +429,9 @@ public class Jedis {
|
||||
Set<Tuple> set = new LinkedHashSet<Tuple>();
|
||||
Iterator<String> iterator = membersWithScores.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
set.add(new Tuple(iterator.next(), Double.valueOf(iterator.next())));
|
||||
set
|
||||
.add(new Tuple(iterator.next(), Double.valueOf(iterator
|
||||
.next())));
|
||||
}
|
||||
return set;
|
||||
}
|
||||
@@ -440,7 +443,9 @@ public class Jedis {
|
||||
Set<Tuple> set = new LinkedHashSet<Tuple>();
|
||||
Iterator<String> iterator = membersWithScores.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
set.add(new Tuple(iterator.next(), Double.valueOf(iterator.next())));
|
||||
set
|
||||
.add(new Tuple(iterator.next(), Double.valueOf(iterator
|
||||
.next())));
|
||||
}
|
||||
return set;
|
||||
}
|
||||
@@ -503,4 +508,15 @@ public class Jedis {
|
||||
return client.getMultiBulkReply();
|
||||
}
|
||||
|
||||
}
|
||||
public List<String> blpop(int timeout, String... keys)
|
||||
throws JedisException {
|
||||
List<String> args = new ArrayList<String>();
|
||||
for (String arg : keys) {
|
||||
args.add(arg);
|
||||
}
|
||||
args.add(String.valueOf(timeout));
|
||||
|
||||
client.blpop(args.toArray(new String[args.size()]));
|
||||
return client.getMultiBulkReply();
|
||||
}
|
||||
}
|
||||
@@ -129,8 +129,11 @@ public class Protocol {
|
||||
}
|
||||
|
||||
private Object processMultiBulkReply(InputStream is) throws JedisException {
|
||||
List<Object> ret = new ArrayList<Object>();
|
||||
int num = Integer.parseInt(readLine(is));
|
||||
if (num == -1) {
|
||||
return null;
|
||||
}
|
||||
List<Object> ret = new ArrayList<Object>();
|
||||
for (int i = 0; i < num; i++) {
|
||||
ret.add(process(is));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user