normalized BinaryJedisCommands to match JedisCommands (including setbit)

This commit is contained in:
samhendley
2012-12-25 16:00:43 -05:00
parent 429e45081e
commit 2006d80ac5
10 changed files with 182 additions and 69 deletions

View File

@@ -135,6 +135,12 @@ public class BinaryJedis implements BinaryJedisCommands {
return client.getIntegerReply();
}
public Long del(final byte[] key) {
checkIsInMulti();
client.del(key);
return client.getIntegerReply();
}
/**
* Return the type of the value stored at key in form of a string. The type
* can be one of "none", "string", "list", "set". "none" is returned if the
@@ -989,7 +995,7 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Multi bulk reply, specifically a list of elements in the
* specified range.
*/
public List<byte[]> lrange(final byte[] key, final int start, final int end) {
public List<byte[]> lrange(final byte[] key, final long start, final long end) {
checkIsInMulti();
client.lrange(key, start, end);
return client.getBinaryMultiBulkReply();
@@ -1029,7 +1035,7 @@ public class BinaryJedis implements BinaryJedisCommands {
* @param end
* @return Status code reply
*/
public String ltrim(final byte[] key, final int start, final int end) {
public String ltrim(final byte[] key, final long start, final long end) {
checkIsInMulti();
client.ltrim(key, start, end);
return client.getStatusCodeReply();
@@ -1053,7 +1059,7 @@ public class BinaryJedis implements BinaryJedisCommands {
* @param index
* @return Bulk reply, specifically the requested element
*/
public byte[] lindex(final byte[] key, final int index) {
public byte[] lindex(final byte[] key, final long index) {
checkIsInMulti();
client.lindex(key, index);
return client.getBinaryBulkReply();
@@ -1080,7 +1086,7 @@ public class BinaryJedis implements BinaryJedisCommands {
* @param value
* @return Status code reply
*/
public String lset(final byte[] key, final int index, final byte[] value) {
public String lset(final byte[] key, final long index, final byte[] value) {
checkIsInMulti();
client.lset(key, index, value);
return client.getStatusCodeReply();
@@ -1105,7 +1111,7 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Integer Reply, specifically: The number of removed elements if
* the operation succeeded
*/
public Long lrem(final byte[] key, final int count, final byte[] value) {
public Long lrem(final byte[] key, final long count, final byte[] value) {
checkIsInMulti();
client.lrem(key, count, value);
return client.getIntegerReply();
@@ -1485,7 +1491,7 @@ public class BinaryJedis implements BinaryJedisCommands {
return client.getIntegerReply();
}
public Set<byte[]> zrange(final byte[] key, final int start, final int end) {
public Set<byte[]> zrange(final byte[] key, final long start, final long end) {
checkIsInMulti();
client.zrange(key, start, end);
final List<byte[]> members = client.getBinaryMultiBulkReply();
@@ -1597,24 +1603,24 @@ public class BinaryJedis implements BinaryJedisCommands {
return client.getIntegerReply();
}
public Set<byte[]> zrevrange(final byte[] key, final int start,
final int end) {
public Set<byte[]> zrevrange(final byte[] key, final long start,
final long end) {
checkIsInMulti();
client.zrevrange(key, start, end);
final List<byte[]> members = client.getBinaryMultiBulkReply();
return new LinkedHashSet<byte[]>(members);
}
public Set<Tuple> zrangeWithScores(final byte[] key, final int start,
final int end) {
public Set<Tuple> zrangeWithScores(final byte[] key, final long start,
final long end) {
checkIsInMulti();
client.zrangeWithScores(key, start, end);
Set<Tuple> set = getBinaryTupledSet();
return set;
}
public Set<Tuple> zrevrangeWithScores(final byte[] key, final int start,
final int end) {
public Set<Tuple> zrevrangeWithScores(final byte[] key, final long start,
final long end) {
checkIsInMulti();
client.zrevrangeWithScores(key, start, end);
Set<Tuple> set = getBinaryTupledSet();
@@ -2020,6 +2026,28 @@ public class BinaryJedis implements BinaryJedisCommands {
return multiBulkReply;
}
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;
}
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;
}
/**
* Request for authentication in a password protected Redis server. A Redis
* server can be instructed to require a password before to allow clients to
@@ -2448,7 +2476,7 @@ public class BinaryJedis implements BinaryJedisCommands {
* operation
*
*/
public Long zremrangeByRank(final byte[] key, final int start, final int end) {
public Long zremrangeByRank(final byte[] key, final long start, final long end) {
checkIsInMulti();
client.zremrangeByRank(key, start, end);
return client.getIntegerReply();
@@ -3026,11 +3054,16 @@ public class BinaryJedis implements BinaryJedisCommands {
* @param value
* @return
*/
public Boolean setbit(byte[] key, long offset, byte[] value) {
public Boolean setbit(byte[] key, long offset, boolean value) {
client.setbit(key, offset, value);
return client.getIntegerReply() == 1;
}
public Boolean setbit(byte[] key, long offset, byte[] value) {
client.setbit(key, offset, value);
return client.getIntegerReply() == 1;
}
/**
* Returns the bit value at offset in the string value stored at key
*
@@ -3048,9 +3081,9 @@ public class BinaryJedis implements BinaryJedisCommands {
return client.getIntegerReply();
}
public String getrange(byte[] key, long startOffset, long endOffset) {
public byte[] getrange(byte[] key, long startOffset, long endOffset) {
client.getrange(key, startOffset, endOffset);
return client.getBulkReply();
return client.getBinaryBulkReply();
}
public Long publish(byte[] channel, byte[] message) {