added binary version of MultiKey commands

This commit is contained in:
samhendley
2012-12-26 10:22:38 -05:00
parent 2006d80ac5
commit cc0ef89b7d
4 changed files with 91 additions and 2 deletions

View File

@@ -17,7 +17,7 @@ import redis.clients.jedis.exceptions.JedisException;
import redis.clients.util.JedisByteHashMap; import redis.clients.util.JedisByteHashMap;
import redis.clients.util.SafeEncoder; import redis.clients.util.SafeEncoder;
public class BinaryJedis implements BinaryJedisCommands { public class BinaryJedis implements BinaryJedisCommands, MultiKeyBinaryCommands {
protected Client client = null; protected Client client = null;
public BinaryJedis(final String host) { public BinaryJedis(final String host) {
@@ -2048,6 +2048,24 @@ public class BinaryJedis implements BinaryJedisCommands {
return multiBulkReply; return multiBulkReply;
} }
public List<byte[]> blpop(byte[]... args) {
checkIsInMulti();
client.blpop(args);
client.setTimeoutInfinite();
final List<byte[]> multiBulkReply = client.getBinaryMultiBulkReply();
client.rollbackTimeout();
return multiBulkReply;
}
public List<byte[]> brpop(byte[]... args) {
checkIsInMulti();
client.brpop(args);
client.setTimeoutInfinite();
final List<byte[]> multiBulkReply = client.getBinaryMultiBulkReply();
client.rollbackTimeout();
return multiBulkReply;
}
/** /**
* Request for authentication in a password protected Redis server. A Redis * Request for authentication in a password protected Redis server. A Redis
* server can be instructed to require a password before to allow clients to * server can be instructed to require a password before to allow clients to

View File

@@ -149,6 +149,8 @@ public interface BinaryJedisCommands {
Set<byte[]> zrangeByScore(byte[] key, double min, double max); Set<byte[]> zrangeByScore(byte[] key, double min, double max);
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);
Set<byte[]> zrangeByScore(byte[] key, double min, double max, int offset, Set<byte[]> zrangeByScore(byte[] key, double min, double max, int offset,

View File

@@ -392,6 +392,10 @@ public class BinaryShardedJedis extends Sharded<Jedis, JedisShardInfo>
return j.zrangeByScoreWithScores(key, min, max, offset, count); 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<Tuple> zrangeByScoreWithScores(byte[] key, byte[] min, byte[] max) { public Set<Tuple> zrangeByScoreWithScores(byte[] key, byte[] min, byte[] max) {
Jedis j = getShard(key); Jedis j = getShard(key);

View File

@@ -0,0 +1,65 @@
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);
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);
byte[] randomBinaryKey();
}