Extract string and binary common interfaces for Pipline and ShardedJedisPipeline. While I'm here add missing binary methods for some bit operations and fix return types for some sharded operations (e.g. getType)

This commit is contained in:
guycoleman
2012-12-04 17:21:43 +00:00
parent 7e95b1500f
commit bf9bba6ef2
4 changed files with 1153 additions and 53 deletions

View File

@@ -0,0 +1,205 @@
package redis.clients.jedis;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author guy
*/
public interface BinaryRedisPipeline {
Response<Long> append(byte[] key, byte[] value);
Response<Long> decr(byte[] key);
Response<Long> decrBy(byte[] key, long integer);
Response<Boolean> exists(byte[] key);
Response<Long> expire(byte[] key, int seconds);
Response<Long> expireAt(byte[] key, long unixTime);
Response<byte[]> get(byte[] key);
Response<Boolean> getbit(byte[] key, long offset);
Response<byte[]> getSet(byte[] key, byte[] value);
Response<Long> getrange(byte[] key, long startOffset, long endOffset);
Response<Long> hdel(byte[] key, byte[] field);
Response<Boolean> hexists(byte[] key, byte[] field);
Response<String> hget(byte[] key, byte[] field);
Response<Map<String, String>> hgetAll(byte[] key);
Response<Long> hincrBy(byte[] key, byte[] field, long value);
Response<Set<String>> hkeys(byte[] key);
Response<Long> hlen(byte[] key);
Response<List<String>> hmget(byte[] key, byte[]... fields);
Response<String> hmset(byte[] key, Map<byte[], byte[]> hash);
Response<Long> hset(byte[] key, byte[] field, byte[] value);
Response<Long> hsetnx(byte[] key, byte[] field, byte[] value);
Response<List<String>> hvals(byte[] key);
Response<Long> incr(byte[] key);
Response<Long> incrBy(byte[] key, long integer);
Response<String> lindex(byte[] key, int index);
Response<Long> linsert(byte[] key, BinaryClient.LIST_POSITION where,
byte[] pivot, byte[] value);
Response<Long> llen(byte[] key);
Response<String> lpop(byte[] key);
Response<Long> lpush(byte[] key, byte[] string);
Response<Long> lpushx(byte[] key, byte[] bytes);
Response<List<String>> lrange(byte[] key, long start, long end);
Response<Long> lrem(byte[] key, long count, byte[] value);
Response<String> lset(byte[] key, long index, byte[] value);
Response<String> ltrim(byte[] key, long start, long end);
Response<Long> persist(byte[] key);
Response<String> rpop(byte[] key);
Response<Long> rpush(byte[] key, byte[] string);
Response<Long> rpushx(byte[] key, byte[] string);
Response<Long> sadd(byte[] key, byte[] member);
Response<Long> scard(byte[] key);
Response<String> set(byte[] key, byte[] value);
Response<Boolean> setbit(byte[] key, long offset, byte[] value);
Response<Long> setrange(byte[] key, long offset, byte[] value);
Response<String> setex(byte[] key, int seconds, byte[] value);
Response<Long> setnx(byte[] key, byte[] value);
Response<Long> setrange(String key, long offset, String value);
Response<Set<String>> smembers(byte[] key);
Response<Boolean> sismember(byte[] key, byte[] member);
Response<Long> sort(byte[] key);
Response<List<String>> sort(byte[] key,
SortingParams sortingParameters);
Response<String> spop(byte[] key);
Response<String> srandmember(byte[] key);
Response<Long> srem(byte[] key, byte[] member);
Response<Long> strlen(byte[] key);
Response<String> substr(byte[] key, int start, int end);
Response<Long> ttl(byte[] key);
Response<String> type(byte[] key);
Response<Long> zadd(byte[] key, double score, byte[] member);
Response<Long> zcard(byte[] key);
Response<Long> zcount(byte[] key, double min, double max);
Response<Double> zincrby(byte[] key, double score, byte[] member);
Response<Set<String>> zrange(byte[] key, int start, int end);
Response<Set<String>> zrangeByScore(byte[] key, double min,
double max);
Response<Set<String>> zrangeByScore(byte[] key, byte[] min,
byte[] max);
Response<Set<String>> zrangeByScore(byte[] key, double min,
double max, int offset, int count);
Response<Set<String>> zrangeByScore(byte[] key, byte[] min,
byte[] max, int offset, int count);
Response<Set<Tuple>> zrangeByScoreWithScores(byte[] key, double min,
double max);
Response<Set<Tuple>> zrangeByScoreWithScores(byte[] key, byte[] min,
byte[] max);
Response<Set<Tuple>> zrangeByScoreWithScores(byte[] key, double min,
double max, int offset, int count);
Response<Set<Tuple>> zrangeByScoreWithScores(byte[] key, byte[] min,
byte[] max, int offset, int count);
Response<Set<String>> zrevrangeByScore(byte[] key, double max,
double min);
Response<Set<String>> zrevrangeByScore(byte[] key, byte[] max,
byte[] min);
Response<Set<String>> zrevrangeByScore(byte[] key, double max,
double min, int offset, int count);
Response<Set<String>> zrevrangeByScore(byte[] key, byte[] max,
byte[] min, int offset, int count);
Response<Set<Tuple>> zrevrangeByScoreWithScores(byte[] key,
double max, double min);
Response<Set<Tuple>> zrevrangeByScoreWithScores(byte[] key,
byte[] max, byte[] min);
Response<Set<Tuple>> zrevrangeByScoreWithScores(byte[] key,
double max, double min, int offset, int count);
Response<Set<Tuple>> zrevrangeByScoreWithScores(byte[] key,
byte[] max, byte[] min, int offset, int count);
Response<Set<Tuple>> zrangeWithScores(byte[] key, int start, int end);
Response<Long> zrank(byte[] key, byte[] member);
Response<Long> zrem(byte[] key, byte[] member);
Response<Long> zremrangeByRank(byte[] key, int start, int end);
Response<Long> zremrangeByScore(byte[] key, double start, double end);
Response<Long> zremrangeByScore(byte[] key, byte[] start, byte[] end);
Response<Set<String>> zrevrange(byte[] key, int start, int end);
Response<Set<Tuple>> zrevrangeWithScores(byte[] key, int start,
int end);
Response<Long> zrevrank(byte[] key, byte[] member);
Response<Double> zscore(byte[] key, byte[] member);
}

View File

@@ -9,7 +9,7 @@ import java.util.Set;
import redis.clients.jedis.BinaryClient.LIST_POSITION; import redis.clients.jedis.BinaryClient.LIST_POSITION;
import redis.clients.jedis.exceptions.JedisDataException; import redis.clients.jedis.exceptions.JedisDataException;
public class Pipeline extends Queable { public class Pipeline extends Queable implements BinaryRedisPipeline, RedisPipeline {
private MultiResponseBuilder currentMulti; private MultiResponseBuilder currentMulti;
@@ -209,6 +209,11 @@ public class Pipeline extends Queable {
return getResponse(BuilderFactory.BOOLEAN); return getResponse(BuilderFactory.BOOLEAN);
} }
public Response<Boolean> getbit(byte[] key, long offset) {
client.getbit(key, offset);
return getResponse(BuilderFactory.BOOLEAN);
}
public Response<String> getrange(String key, long startOffset, public Response<String> getrange(String key, long startOffset,
long endOffset) { long endOffset) {
client.getrange(key, startOffset, endOffset); client.getrange(key, startOffset, endOffset);
@@ -225,6 +230,11 @@ public class Pipeline extends Queable {
return getResponse(BuilderFactory.BYTE_ARRAY); return getResponse(BuilderFactory.BYTE_ARRAY);
} }
public Response<Long> getrange(byte[] key, long startOffset, long endOffset) {
client.getrange(key, startOffset, endOffset);
return getResponse(BuilderFactory.LONG);
}
public Response<Long> hdel(String key, String field) { public Response<Long> hdel(String key, String field) {
client.hdel(key, field); client.hdel(key, field);
return getResponse(BuilderFactory.LONG); return getResponse(BuilderFactory.LONG);
@@ -642,6 +652,11 @@ public class Pipeline extends Queable {
return getResponse(BuilderFactory.BOOLEAN); return getResponse(BuilderFactory.BOOLEAN);
} }
public Response<Boolean> setbit(byte[] key, long offset, byte[] value) {
client.setbit(key, offset, value);
return getResponse(BuilderFactory.BOOLEAN);
}
public Response<String> setex(String key, int seconds, String value) { public Response<String> setex(String key, int seconds, String value) {
client.setex(key, seconds, value); client.setex(key, seconds, value);
return getResponse(BuilderFactory.STRING); return getResponse(BuilderFactory.STRING);
@@ -667,6 +682,11 @@ public class Pipeline extends Queable {
return getResponse(BuilderFactory.LONG); return getResponse(BuilderFactory.LONG);
} }
public Response<Long> setrange(byte[] key, long offset, byte[] value) {
client.setrange(key, offset, value);
return getResponse(BuilderFactory.LONG);
}
public Response<Set<String>> sinter(String... keys) { public Response<Set<String>> sinter(String... keys) {
client.sinter(keys); client.sinter(keys);
return getResponse(BuilderFactory.STRING_SET); return getResponse(BuilderFactory.STRING_SET);

View File

@@ -0,0 +1,184 @@
package redis.clients.jedis;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author guy
*/
public interface RedisPipeline {
Response<Long> append(String key, String value);
Response<Long> decr(String key);
Response<Long> decrBy(String key, long integer);
Response<Boolean> exists(String key);
Response<Long> expire(String key, int seconds);
Response<Long> expireAt(String key, long unixTime);
Response<String> get(String key);
Response<Boolean> getbit(String key, long offset);
Response<String> getrange(String key, long startOffset,
long endOffset);
Response<String> getSet(String key, String value);
Response<Long> hdel(String key, String field);
Response<Boolean> hexists(String key, String field);
Response<String> hget(String key, String field);
Response<Map<String, String>> hgetAll(String key);
Response<Long> hincrBy(String key, String field, long value);
Response<Set<String>> hkeys(String key);
Response<Long> hlen(String key);
Response<List<String>> hmget(String key, String... fields);
Response<String> hmset(String key, Map<String, String> hash);
Response<Long> hset(String key, String field, String value);
Response<Long> hsetnx(String key, String field, String value);
Response<List<String>> hvals(String key);
Response<Long> incr(String key);
Response<Long> incrBy(String key, long integer);
Response<String> lindex(String key, int index);
Response<Long> linsert(String key, BinaryClient.LIST_POSITION where,
String pivot, String value);
Response<Long> llen(String key);
Response<String> lpop(String key);
Response<Long> lpush(String key, String string);
Response<Long> lpushx(String key, String string);
Response<List<String>> lrange(String key, long start, long end);
Response<Long> lrem(String key, long count, String value);
Response<String> lset(String key, long index, String value);
Response<String> ltrim(String key, long start, long end);
Response<Long> persist(String key);
Response<String> rpop(String key);
Response<Long> rpush(String key, String string);
Response<Long> rpushx(String key, String string);
Response<Long> sadd(String key, String member);
Response<Long> scard(String key);
Response<Boolean> sismember(String key, String member);
Response<String> set(String key, String value);
Response<Boolean> setbit(String key, long offset, boolean value);
Response<String> setex(String key, int seconds, String value);
Response<Long> setnx(String key, String value);
Response<Set<String>> smembers(String key);
Response<Long> sort(String key);
Response<List<String>> sort(String key,
SortingParams sortingParameters);
Response<String> spop(String key);
Response<String> srandmember(String key);
Response<Long> srem(String key, String member);
Response<Long> strlen(String key);
Response<String> substr(String key, int start, int end);
Response<Long> ttl(String key);
Response<String> type(String key);
Response<Long> zadd(String key, double score, String member);
Response<Long> zcard(String key);
Response<Long> zcount(String key, double min, double max);
Response<Double> zincrby(String key, double score, String member);
Response<Set<String>> zrange(String key, int start, int end);
Response<Set<String>> zrangeByScore(String key, double min,
double max);
Response<Set<String>> zrangeByScore(String key, String min,
String max);
Response<Set<String>> zrangeByScore(String key, double min,
double max, int offset, int count);
Response<Set<Tuple>> zrangeByScoreWithScores(String key, double min,
double max);
Response<Set<Tuple>> zrangeByScoreWithScores(String key, double min,
double max, int offset, int count);
Response<Set<String>> zrevrangeByScore(String key, double max,
double min);
Response<Set<String>> zrevrangeByScore(String key, String max,
String min);
Response<Set<String>> zrevrangeByScore(String key, double max,
double min, int offset, int count);
Response<Set<Tuple>> zrevrangeByScoreWithScores(String key,
double max, double min);
Response<Set<Tuple>> zrevrangeByScoreWithScores(String key,
double max, double min, int offset, int count);
Response<Set<Tuple>> zrangeWithScores(String key, int start, int end);
Response<Long> zrank(String key, String member);
Response<Long> zrem(String key, String member);
Response<Long> zremrangeByRank(String key, int start, int end);
Response<Long> zremrangeByScore(String key, double start, double end);
Response<Set<String>> zrevrange(String key, int start, int end);
Response<Set<Tuple>> zrevrangeWithScores(String key, int start,
int end);
Response<Long> zrevrank(String key, String member);
Response<Double> zscore(String key, String member);
}

File diff suppressed because it is too large Load Diff