Merge pull request #121 from ewhauser/master
Fix bug in getbit/setbit and add bit commands to ShardedJedisPipeline
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
import static redis.clients.jedis.Protocol.toByteArray;
|
||||
import redis.clients.util.SafeEncoder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import redis.clients.util.SafeEncoder;
|
||||
import static redis.clients.jedis.Protocol.toByteArray;
|
||||
|
||||
public class Client extends BinaryClient implements Commands {
|
||||
public Client(final String host) {
|
||||
@@ -537,7 +537,7 @@ public class Client extends BinaryClient implements Commands {
|
||||
}
|
||||
|
||||
public void setbit(final String key, final long offset, final boolean value) {
|
||||
setbit(SafeEncoder.encode(key), offset, toByteArray(value ? 0 : 1));
|
||||
setbit(SafeEncoder.encode(key), offset, toByteArray(value ? 1 : 0));
|
||||
}
|
||||
|
||||
public void getbit(String key, long offset) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
import redis.clients.jedis.BinaryClient.LIST_POSITION;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import redis.clients.jedis.BinaryClient.LIST_POSITION;
|
||||
|
||||
public abstract class ShardedJedisPipeline {
|
||||
private BinaryShardedJedis jedis;
|
||||
private List<FutureResult> results = new ArrayList<FutureResult>();
|
||||
@@ -425,6 +425,30 @@ public abstract class ShardedJedisPipeline {
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
protected void getbit(String key, long offset) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.getbit(key, offset);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
public void setbit(String key, long offset, boolean value) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.setbit(key, offset, value);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
public void setrange(String key, long offset, String value) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.setrange(key, offset, value);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
public void getrange(String key, long startOffset, long endOffset) {
|
||||
Client c = jedis.getShard(key).getClient();
|
||||
c.getrange(key, startOffset, endOffset);
|
||||
results.add(new FutureResult(c));
|
||||
}
|
||||
|
||||
public List<Object> getResults() {
|
||||
List<Object> r = new ArrayList<Object>();
|
||||
for (FutureResult fr : results) {
|
||||
|
||||
Reference in New Issue
Block a user