Now methods accepting infinit and exclusions are supported as String and byte[] overloads

This commit is contained in:
ivowiblo
2012-05-03 23:30:44 -04:00
parent 5244d82450
commit 129e358c9d
12 changed files with 448 additions and 89 deletions

View File

@@ -527,18 +527,8 @@ public class BinaryClient extends Connection {
sendCommand(PUNSUBSCRIBE, patterns); sendCommand(PUNSUBSCRIBE, patterns);
} }
public void zcount(final byte[] key, final double min, final double max) { public void zcount(final byte[] key, final byte[] min, final byte[] max) {
sendCommand(ZCOUNT, key, toByteArray(min), toByteArray(max)); sendCommand(ZCOUNT, key, min, max);
}
public void zrangeByScore(final byte[] key, final double min,
final double max) {
sendCommand(ZRANGEBYSCORE, key, toByteArray(min), toByteArray(max));
}
public void zrevrangeByScore(final byte[] key, final double max,
final double min) {
sendCommand(ZREVRANGEBYSCORE, key, toByteArray(max), toByteArray(min));
} }
public void zrangeByScore(final byte[] key, final byte[] min, public void zrangeByScore(final byte[] key, final byte[] min,
@@ -551,40 +541,40 @@ public class BinaryClient extends Connection {
sendCommand(ZREVRANGEBYSCORE, key, max, min); sendCommand(ZREVRANGEBYSCORE, key, max, min);
} }
public void zrangeByScore(final byte[] key, final double min, public void zrangeByScore(final byte[] key, final byte[] min,
final double max, final int offset, int count) { final byte[] max, final int offset, int count) {
sendCommand(ZRANGEBYSCORE, key, toByteArray(min), toByteArray(max), sendCommand(ZRANGEBYSCORE, key, min, max,
LIMIT.raw, toByteArray(offset), toByteArray(count)); LIMIT.raw, toByteArray(offset), toByteArray(count));
} }
public void zrevrangeByScore(final byte[] key, final double max, public void zrevrangeByScore(final byte[] key, final byte[] max,
final double min, final int offset, int count) { final byte[] min, final int offset, int count) {
sendCommand(ZREVRANGEBYSCORE, key, toByteArray(max), toByteArray(min), sendCommand(ZREVRANGEBYSCORE, key, max, min,
LIMIT.raw, toByteArray(offset), toByteArray(count)); LIMIT.raw, toByteArray(offset), toByteArray(count));
} }
public void zrangeByScoreWithScores(final byte[] key, final double min, public void zrangeByScoreWithScores(final byte[] key, final byte[] min,
final double max) { final byte[] max) {
sendCommand(ZRANGEBYSCORE, key, toByteArray(min), toByteArray(max), sendCommand(ZRANGEBYSCORE, key, min, max,
WITHSCORES.raw); WITHSCORES.raw);
} }
public void zrevrangeByScoreWithScores(final byte[] key, final double max, public void zrevrangeByScoreWithScores(final byte[] key, final byte[] max,
final double min) { final byte[] min) {
sendCommand(ZREVRANGEBYSCORE, key, toByteArray(max), toByteArray(min), sendCommand(ZREVRANGEBYSCORE, key, max, min,
WITHSCORES.raw); WITHSCORES.raw);
} }
public void zrangeByScoreWithScores(final byte[] key, final double min, public void zrangeByScoreWithScores(final byte[] key, final byte[] min,
final double max, final int offset, final int count) { final byte[] max, final int offset, final int count) {
sendCommand(ZRANGEBYSCORE, key, toByteArray(min), toByteArray(max), sendCommand(ZRANGEBYSCORE, key, min, max,
LIMIT.raw, toByteArray(offset), toByteArray(count), LIMIT.raw, toByteArray(offset), toByteArray(count),
WITHSCORES.raw); WITHSCORES.raw);
} }
public void zrevrangeByScoreWithScores(final byte[] key, final double max, public void zrevrangeByScoreWithScores(final byte[] key, final byte[] max,
final double min, final int offset, final int count) { final byte[] min, final int offset, final int count) {
sendCommand(ZREVRANGEBYSCORE, key, toByteArray(max), toByteArray(min), sendCommand(ZREVRANGEBYSCORE, key, max, min,
LIMIT.raw, toByteArray(offset), toByteArray(count), LIMIT.raw, toByteArray(offset), toByteArray(count),
WITHSCORES.raw); WITHSCORES.raw);
} }
@@ -593,9 +583,9 @@ public class BinaryClient extends Connection {
sendCommand(ZREMRANGEBYRANK, key, toByteArray(start), toByteArray(end)); sendCommand(ZREMRANGEBYRANK, key, toByteArray(start), toByteArray(end));
} }
public void zremrangeByScore(final byte[] key, final double start, public void zremrangeByScore(final byte[] key, final byte[] start,
final double end) { final byte[] end) {
sendCommand(ZREMRANGEBYSCORE, key, toByteArray(start), toByteArray(end)); sendCommand(ZREMRANGEBYSCORE, key, start, end);
} }
public void zunionstore(final byte[] dstkey, final byte[]... sets) { public void zunionstore(final byte[] dstkey, final byte[]... sets) {

View File

@@ -2064,11 +2064,15 @@ public class BinaryJedis implements BinaryJedisCommands {
} }
public Long zcount(final byte[] key, final double min, final double max) { public Long zcount(final byte[] key, final double min, final double max) {
checkIsInMulti(); return zcount(key, toByteArray(min), toByteArray(max));
client.zcount(key, min, max);
return client.getIntegerReply();
} }
public Long zcount(final byte[] key, final byte[] min, final byte[] max) {
checkIsInMulti();
client.zcount(key, min, max);
return client.getIntegerReply();
}
/** /**
* Return the all the elements in the sorted set at key with a score between * Return the all the elements in the sorted set at key with a score between
* min and max (including elements with score equal to min or max). * min and max (including elements with score equal to min or max).
@@ -2127,10 +2131,8 @@ public class BinaryJedis implements BinaryJedisCommands {
*/ */
public Set<byte[]> zrangeByScore(final byte[] key, final double min, public Set<byte[]> zrangeByScore(final byte[] key, final double min,
final double max) { final double max) {
checkIsInMulti(); return zrangeByScore(key, toByteArray(min), toByteArray(max));
client.zrangeByScore(key, min, max); }
return new LinkedHashSet<byte[]>(client.getBinaryMultiBulkReply());
}
public Set<byte[]> zrangeByScore(final byte[] key, final byte[] min, public Set<byte[]> zrangeByScore(final byte[] key, final byte[] min,
final byte[] max) { final byte[] max) {
@@ -2197,10 +2199,15 @@ public class BinaryJedis implements BinaryJedisCommands {
*/ */
public Set<byte[]> zrangeByScore(final byte[] key, final double min, public Set<byte[]> zrangeByScore(final byte[] key, final double min,
final double max, final int offset, final int count) { final double max, final int offset, final int count) {
checkIsInMulti(); return zrangeByScore(key, toByteArray(min),toByteArray(max),offset, count);
client.zrangeByScore(key, min, max, offset, count);
return new LinkedHashSet<byte[]>(client.getBinaryMultiBulkReply());
} }
public Set<byte[]> zrangeByScore(final byte[] key, final byte[] min,
final byte[] max, final int offset, final int count) {
checkIsInMulti();
client.zrangeByScore(key, min, max, offset, count);
return new LinkedHashSet<byte[]>(client.getBinaryMultiBulkReply());
}
/** /**
* Return the all the elements in the sorted set at key with a score between * Return the all the elements in the sorted set at key with a score between
@@ -2260,11 +2267,16 @@ public class BinaryJedis implements BinaryJedisCommands {
*/ */
public Set<Tuple> zrangeByScoreWithScores(final byte[] key, public Set<Tuple> zrangeByScoreWithScores(final byte[] key,
final double min, final double max) { final double min, final double max) {
checkIsInMulti(); return zrangeByScoreWithScores(key, toByteArray(min), toByteArray(max));
client.zrangeByScoreWithScores(key, min, max);
Set<Tuple> set = getBinaryTupledSet();
return set;
} }
public Set<Tuple> zrangeByScoreWithScores(final byte[] key,
final byte[] min, final byte[] max) {
checkIsInMulti();
client.zrangeByScoreWithScores(key, min, max);
Set<Tuple> set = getBinaryTupledSet();
return set;
}
/** /**
* Return the all the elements in the sorted set at key with a score between * Return the all the elements in the sorted set at key with a score between
@@ -2325,11 +2337,17 @@ public class BinaryJedis implements BinaryJedisCommands {
public Set<Tuple> zrangeByScoreWithScores(final byte[] key, public Set<Tuple> zrangeByScoreWithScores(final byte[] key,
final double min, final double max, final int offset, final double min, final double max, final int offset,
final int count) { final int count) {
checkIsInMulti(); return zrangeByScoreWithScores(key, toByteArray(min), toByteArray(max), offset, count);
client.zrangeByScoreWithScores(key, min, max, offset, count);
Set<Tuple> set = getBinaryTupledSet();
return set;
} }
public Set<Tuple> zrangeByScoreWithScores(final byte[] key,
final byte[] min, final byte[] max, final int offset,
final int count) {
checkIsInMulti();
client.zrangeByScoreWithScores(key, min, max, offset, count);
Set<Tuple> set = getBinaryTupledSet();
return set;
}
private Set<Tuple> getBinaryTupledSet() { private Set<Tuple> getBinaryTupledSet() {
checkIsInMulti(); checkIsInMulti();
@@ -2345,9 +2363,7 @@ public class BinaryJedis implements BinaryJedisCommands {
public Set<byte[]> zrevrangeByScore(final byte[] key, final double max, public Set<byte[]> zrevrangeByScore(final byte[] key, final double max,
final double min) { final double min) {
checkIsInMulti(); return zrevrangeByScore(key, toByteArray(max), toByteArray(min));
client.zrevrangeByScore(key, max, min);
return new LinkedHashSet<byte[]>(client.getBinaryMultiBulkReply());
} }
public Set<byte[]> zrevrangeByScore(final byte[] key, final byte[] max, public Set<byte[]> zrevrangeByScore(final byte[] key, final byte[] max,
@@ -2359,13 +2375,29 @@ public class BinaryJedis implements BinaryJedisCommands {
public Set<byte[]> zrevrangeByScore(final byte[] key, final double max, public Set<byte[]> zrevrangeByScore(final byte[] key, final double max,
final double min, final int offset, final int count) { final double min, final int offset, final int count) {
checkIsInMulti(); return zrevrangeByScore(key, toByteArray(max), toByteArray(min), offset, count);
client.zrevrangeByScore(key, max, min, offset, count);
return new LinkedHashSet<byte[]>(client.getBinaryMultiBulkReply());
} }
public Set<byte[]> zrevrangeByScore(final byte[] key, final byte[] max,
final byte[] min, final int offset, final int count) {
checkIsInMulti();
client.zrevrangeByScore(key, max, min, offset, count);
return new LinkedHashSet<byte[]>(client.getBinaryMultiBulkReply());
}
public Set<Tuple> zrevrangeByScoreWithScores(final byte[] key, public Set<Tuple> zrevrangeByScoreWithScores(final byte[] key,
final double max, final double min) { final double max, final double min) {
return zrevrangeByScoreWithScores(key, toByteArray(max), toByteArray(min));
}
public Set<Tuple> zrevrangeByScoreWithScores(final byte[] key,
final double max, final double min, final int offset,
final int count) {
return zrevrangeByScoreWithScores(key, toByteArray(max), toByteArray(min), offset, count);
}
public Set<Tuple> zrevrangeByScoreWithScores(final byte[] key,
final byte[] max, final byte[] min) {
checkIsInMulti(); checkIsInMulti();
client.zrevrangeByScoreWithScores(key, max, min); client.zrevrangeByScoreWithScores(key, max, min);
Set<Tuple> set = getBinaryTupledSet(); Set<Tuple> set = getBinaryTupledSet();
@@ -2373,13 +2405,13 @@ public class BinaryJedis implements BinaryJedisCommands {
} }
public Set<Tuple> zrevrangeByScoreWithScores(final byte[] key, public Set<Tuple> zrevrangeByScoreWithScores(final byte[] key,
final double max, final double min, final int offset, final byte[] max, final byte[] min, final int offset,
final int count) { final int count) {
checkIsInMulti(); checkIsInMulti();
client.zrevrangeByScoreWithScores(key, max, min, offset, count); client.zrevrangeByScoreWithScores(key, max, min, offset, count);
Set<Tuple> set = getBinaryTupledSet(); Set<Tuple> set = getBinaryTupledSet();
return set; return set;
} }
/** /**
* Remove all elements in the sorted set at key with rank between start and * Remove all elements in the sorted set at key with rank between start and
@@ -2416,10 +2448,15 @@ public class BinaryJedis implements BinaryJedisCommands {
*/ */
public Long zremrangeByScore(final byte[] key, final double start, public Long zremrangeByScore(final byte[] key, final double start,
final double end) { final double end) {
checkIsInMulti(); return zremrangeByScore(key, toByteArray(start), toByteArray(end));
client.zremrangeByScore(key, start, end);
return client.getIntegerReply();
} }
public Long zremrangeByScore(final byte[] key, final byte[] start,
final byte[] end) {
checkIsInMulti();
client.zremrangeByScore(key, start, end);
return client.getIntegerReply();
}
/** /**
* Creates a union or intersection of N sorted sets given by keys k1 through * Creates a union or intersection of N sorted sets given by keys k1 through

View File

@@ -131,6 +131,8 @@ public interface BinaryJedisCommands {
Long zcount(byte[] key, double min, double max); Long zcount(byte[] key, double min, double max);
Long zcount(byte[] key, byte[] min, byte[] max);
Set<byte[]> zrangeByScore(byte[] key, double min, double max); Set<byte[]> zrangeByScore(byte[] key, double min, double max);
Set<byte[]> zrangeByScore(byte[] key, double min, double max, int offset, Set<byte[]> zrangeByScore(byte[] key, double min, double max, int offset,
@@ -141,20 +143,37 @@ public interface BinaryJedisCommands {
Set<Tuple> zrangeByScoreWithScores(byte[] key, double min, double max, Set<Tuple> zrangeByScoreWithScores(byte[] key, double min, double max,
int offset, int count); int offset, int count);
Set<Tuple> zrangeByScoreWithScores(byte[] key, byte[] min, byte[] max);
Set<Tuple> zrangeByScoreWithScores(byte[] key, byte[] min, byte[] max,
int offset, int count);
Set<byte[]> zrevrangeByScore(byte[] key, double max, double min); Set<byte[]> zrevrangeByScore(byte[] key, double max, double min);
Set<byte[]> zrevrangeByScore(byte[] key, double max, double min, Set<byte[]> zrevrangeByScore(byte[] key, double max, double min,
int offset, int count); int offset, int count);
Set<byte[]> zrevrangeByScore(byte[] key, byte[] max, byte[] min);
Set<byte[]> zrevrangeByScore(byte[] key, byte[] max, byte[] min,
int offset, int count);
Set<Tuple> zrevrangeByScoreWithScores(byte[] key, double max, double min); Set<Tuple> zrevrangeByScoreWithScores(byte[] key, double max, double min);
Set<Tuple> zrevrangeByScoreWithScores(byte[] key, double max, double min, Set<Tuple> zrevrangeByScoreWithScores(byte[] key, double max, double min,
int offset, int count); int offset, int count);
Set<Tuple> zrevrangeByScoreWithScores(byte[] key, byte[] max, byte[] min);
Set<Tuple> zrevrangeByScoreWithScores(byte[] key, byte[] max, byte[] min,
int offset, int count);
Long zremrangeByRank(byte[] key, int start, int end); Long zremrangeByRank(byte[] key, int start, int end);
Long zremrangeByScore(byte[] key, double start, double end); Long zremrangeByScore(byte[] key, double start, double end);
Long zremrangeByScore(byte[] key, byte[] start, byte[] end);
Long linsert(byte[] key, LIST_POSITION where, byte[] pivot, byte[] value); Long linsert(byte[] key, LIST_POSITION where, byte[] pivot, byte[] value);
Long objectRefcount(byte[] key); Long objectRefcount(byte[] key);

View File

@@ -339,6 +339,11 @@ public class BinaryShardedJedis extends Sharded<Jedis, JedisShardInfo>
Jedis j = getShard(key); Jedis j = getShard(key);
return j.zcount(key, min, max); return j.zcount(key, min, max);
} }
public Long zcount(byte[] key, byte[] min, byte[] max) {
Jedis j = getShard(key);
return j.zcount(key, min, max);
}
public Set<byte[]> zrangeByScore(byte[] key, double min, double max) { public Set<byte[]> zrangeByScore(byte[] key, double min, double max) {
Jedis j = getShard(key); Jedis j = getShard(key);
@@ -361,6 +366,18 @@ public class BinaryShardedJedis extends Sharded<Jedis, JedisShardInfo>
Jedis j = getShard(key); Jedis j = getShard(key);
return j.zrangeByScoreWithScores(key, min, max, offset, count); return j.zrangeByScoreWithScores(key, min, max, offset, count);
} }
public Set<Tuple> zrangeByScoreWithScores(byte[] key, byte[] min, byte[] max) {
Jedis j = getShard(key);
return j.zrangeByScoreWithScores(key, min, max);
}
public Set<Tuple> zrangeByScoreWithScores(byte[] key, byte[] min,
byte[] max, int offset, int count) {
Jedis j = getShard(key);
return j.zrangeByScoreWithScores(key, min, max, offset, count);
}
public Set<byte[]> zrevrangeByScore(byte[] key, double max, double min) { public Set<byte[]> zrevrangeByScore(byte[] key, double max, double min) {
Jedis j = getShard(key); Jedis j = getShard(key);
@@ -384,6 +401,29 @@ public class BinaryShardedJedis extends Sharded<Jedis, JedisShardInfo>
Jedis j = getShard(key); Jedis j = getShard(key);
return j.zrevrangeByScoreWithScores(key, max, min, offset, count); return j.zrevrangeByScoreWithScores(key, max, min, offset, count);
} }
public Set<byte[]> zrevrangeByScore(byte[] key, byte[] max, byte[] min) {
Jedis j = getShard(key);
return j.zrevrangeByScore(key, max, min);
}
public Set<byte[]> zrevrangeByScore(byte[] key, byte[] max, byte[] min,
int offset, int count) {
Jedis j = getShard(key);
return j.zrevrangeByScore(key, max, min, offset, count);
}
public Set<Tuple> zrevrangeByScoreWithScores(byte[] key, byte[] max,
byte[] min) {
Jedis j = getShard(key);
return j.zrevrangeByScoreWithScores(key, max, min);
}
public Set<Tuple> zrevrangeByScoreWithScores(byte[] key, byte[] max,
byte[] min, int offset, int count) {
Jedis j = getShard(key);
return j.zrevrangeByScoreWithScores(key, max, min, offset, count);
}
public Long zremrangeByRank(byte[] key, int start, int end) { public Long zremrangeByRank(byte[] key, int start, int end) {
Jedis j = getShard(key); Jedis j = getShard(key);
@@ -395,6 +435,11 @@ public class BinaryShardedJedis extends Sharded<Jedis, JedisShardInfo>
return j.zremrangeByScore(key, start, end); return j.zremrangeByScore(key, start, end);
} }
public Long zremrangeByScore(byte[] key, byte[] start, byte[] end) {
Jedis j = getShard(key);
return j.zremrangeByScore(key, start, end);
}
public Long linsert(byte[] key, LIST_POSITION where, byte[] pivot, public Long linsert(byte[] key, LIST_POSITION where, byte[] pivot,
byte[] value) { byte[] value) {
Jedis j = getShard(key); Jedis j = getShard(key);

View File

@@ -1,5 +1,7 @@
package redis.clients.jedis; package redis.clients.jedis;
import static redis.clients.jedis.Protocol.toByteArray;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -446,6 +448,10 @@ public class BinaryTransaction extends Queable {
} }
public Response<Long> zcount(byte[] key, double min, double max) { public Response<Long> zcount(byte[] key, double min, double max) {
return zcount(key, toByteArray(min), toByteArray(max));
}
public Response<Long> zcount(byte[] key, byte[] min, byte[] max) {
client.zcount(key, min, max); client.zcount(key, min, max);
return getResponse(BuilderFactory.LONG); return getResponse(BuilderFactory.LONG);
} }
@@ -473,30 +479,44 @@ public class BinaryTransaction extends Queable {
public Response<Set<byte[]>> zrangeByScore(byte[] key, double min, public Response<Set<byte[]>> zrangeByScore(byte[] key, double min,
double max) { double max) {
return zrangeByScore(key, toByteArray(min), toByteArray(max));
}
public Response<Set<byte[]>> zrangeByScore(byte[] key, byte[] min,
byte[] max) {
client.zrangeByScore(key, min, max); client.zrangeByScore(key, min, max);
return getResponse(BuilderFactory.BYTE_ARRAY_ZSET); return getResponse(BuilderFactory.BYTE_ARRAY_ZSET);
} }
public Response<Set<byte[]>> zrangeByScore(byte[] key, byte[] min, public Response<Set<byte[]>> zrangeByScore(byte[] key, byte[] min,
byte[] max) { byte[] max, int offset, int count) {
client.zrangeByScore(key, min, max);
return getResponse(BuilderFactory.BYTE_ARRAY_ZSET);
}
public Response<Set<byte[]>> zrangeByScore(byte[] key, double min,
double max, int offset, int count) {
client.zrangeByScore(key, min, max, offset, count); client.zrangeByScore(key, min, max, offset, count);
return getResponse(BuilderFactory.BYTE_ARRAY_ZSET); return getResponse(BuilderFactory.BYTE_ARRAY_ZSET);
} }
public Response<Set<byte[]>> zrangeByScore(byte[] key, double min,
double max, int offset, int count) {
return zrangeByScore(key, toByteArray(min), toByteArray(max), offset, count);
}
public Response<Set<Tuple>> zrangeByScoreWithScores(byte[] key, double min, public Response<Set<Tuple>> zrangeByScoreWithScores(byte[] key, double min,
double max) { double max) {
client.zrangeByScoreWithScores(key, min, max); return zrangeByScoreWithScores(key, toByteArray(min), toByteArray(max));
return getResponse(BuilderFactory.TUPLE_ZSET_BINARY);
} }
public Response<Set<Tuple>> zrangeByScoreWithScores(byte[] key, double min, public Response<Set<Tuple>> zrangeByScoreWithScores(byte[] key, double min,
double max, int offset, int count) { double max, int offset, int count) {
return zrangeByScoreWithScores(key, toByteArray(min), toByteArray(max), offset, count);
}
public Response<Set<Tuple>> zrangeByScoreWithScores(byte[] key, byte[] min,
byte[] max) {
client.zrangeByScoreWithScores(key, min, max);
return getResponse(BuilderFactory.TUPLE_ZSET_BINARY);
}
public Response<Set<Tuple>> zrangeByScoreWithScores(byte[] key, byte[] min,
byte[] max, int offset, int count) {
client.zrangeByScoreWithScores(key, min, max, offset, count); client.zrangeByScoreWithScores(key, min, max, offset, count);
return getResponse(BuilderFactory.TUPLE_ZSET_BINARY); return getResponse(BuilderFactory.TUPLE_ZSET_BINARY);
} }
@@ -522,6 +542,10 @@ public class BinaryTransaction extends Queable {
} }
public Response<Long> zremrangeByScore(byte[] key, double start, double end) { public Response<Long> zremrangeByScore(byte[] key, double start, double end) {
return zremrangeByScore(key, toByteArray(start), toByteArray(end));
}
public Response<Long> zremrangeByScore(byte[] key, byte[] start, byte[] end) {
client.zremrangeByScore(key, start, end); client.zremrangeByScore(key, start, end);
return getResponse(BuilderFactory.LONG); return getResponse(BuilderFactory.LONG);
} }

View File

@@ -405,12 +405,16 @@ public class Client extends BinaryClient implements Commands {
} }
public void zcount(final String key, final double min, final double max) { public void zcount(final String key, final double min, final double max) {
zcount(SafeEncoder.encode(key), min, max); zcount(SafeEncoder.encode(key), toByteArray(min), toByteArray(max));
}
public void zcount(final String key, final String min, final String max) {
zcount(SafeEncoder.encode(key), SafeEncoder.encode(min), SafeEncoder.encode(max));
} }
public void zrangeByScore(final String key, final double min, public void zrangeByScore(final String key, final double min,
final double max) { final double max) {
zrangeByScore(SafeEncoder.encode(key), min, max); zrangeByScore(SafeEncoder.encode(key), toByteArray(min), toByteArray(max));
} }
public void zrangeByScore(final String key, final String min, public void zrangeByScore(final String key, final String min,
@@ -421,23 +425,39 @@ public class Client extends BinaryClient implements Commands {
public void zrangeByScore(final String key, final double min, public void zrangeByScore(final String key, final double min,
final double max, final int offset, int count) { final double max, final int offset, int count) {
zrangeByScore(SafeEncoder.encode(key), min, max, offset, count); zrangeByScore(SafeEncoder.encode(key), toByteArray(min), toByteArray(max), offset, count);
} }
public void zrangeByScoreWithScores(final String key, final double min, public void zrangeByScoreWithScores(final String key, final double min,
final double max) { final double max) {
zrangeByScoreWithScores(SafeEncoder.encode(key), min, max); zrangeByScoreWithScores(SafeEncoder.encode(key), toByteArray(min), toByteArray(max));
} }
public void zrangeByScoreWithScores(final String key, final double min, public void zrangeByScoreWithScores(final String key, final double min,
final double max, final int offset, final int count) { final double max, final int offset, final int count) {
zrangeByScoreWithScores(SafeEncoder.encode(key), min, max, offset, zrangeByScoreWithScores(SafeEncoder.encode(key), toByteArray(min), toByteArray(max), offset,
count); count);
} }
public void zrevrangeByScore(final String key, final double max, public void zrevrangeByScore(final String key, final double max,
final double min) { final double min) {
zrevrangeByScore(SafeEncoder.encode(key), max, min); zrevrangeByScore(SafeEncoder.encode(key), toByteArray(max), toByteArray(min));
}
public void zrangeByScore(final String key, final String min,
final String max, final int offset, int count) {
zrangeByScore(SafeEncoder.encode(key), SafeEncoder.encode(min), SafeEncoder.encode(max), offset, count);
}
public void zrangeByScoreWithScores(final String key, final String min,
final String max) {
zrangeByScoreWithScores(SafeEncoder.encode(key), SafeEncoder.encode(min), SafeEncoder.encode(max));
}
public void zrangeByScoreWithScores(final String key, final String min,
final String max, final int offset, final int count) {
zrangeByScoreWithScores(SafeEncoder.encode(key), SafeEncoder.encode(min), SafeEncoder.encode(max), offset,
count);
} }
public void zrevrangeByScore(final String key, final String max, public void zrevrangeByScore(final String key, final String max,
@@ -448,19 +468,35 @@ public class Client extends BinaryClient implements Commands {
public void zrevrangeByScore(final String key, final double max, public void zrevrangeByScore(final String key, final double max,
final double min, final int offset, int count) { final double min, final int offset, int count) {
zrevrangeByScore(SafeEncoder.encode(key), max, min, offset, count); zrevrangeByScore(SafeEncoder.encode(key), toByteArray(max), toByteArray(min), offset, count);
}
public void zrevrangeByScore(final String key, final String max,
final String min, final int offset, int count) {
zrevrangeByScore(SafeEncoder.encode(key), SafeEncoder.encode(max), SafeEncoder.encode(min), offset, count);
} }
public void zrevrangeByScoreWithScores(final String key, final double max, public void zrevrangeByScoreWithScores(final String key, final double max,
final double min) { final double min) {
zrevrangeByScoreWithScores(SafeEncoder.encode(key), max, min); zrevrangeByScoreWithScores(SafeEncoder.encode(key), toByteArray(max), toByteArray(min));
} }
public void zrevrangeByScoreWithScores(final String key, final String max,
final String min) {
zrevrangeByScoreWithScores(SafeEncoder.encode(key), SafeEncoder.encode(max), SafeEncoder.encode(min));
}
public void zrevrangeByScoreWithScores(final String key, final double max, public void zrevrangeByScoreWithScores(final String key, final double max,
final double min, final int offset, final int count) { final double min, final int offset, final int count) {
zrevrangeByScoreWithScores(SafeEncoder.encode(key), max, min, offset, zrevrangeByScoreWithScores(SafeEncoder.encode(key), toByteArray(max), toByteArray(min), offset,
count); count);
} }
public void zrevrangeByScoreWithScores(final String key, final String max,
final String min, final int offset, final int count) {
zrevrangeByScoreWithScores(SafeEncoder.encode(key), SafeEncoder.encode(max), SafeEncoder.encode(min), offset,
count);
}
public void zremrangeByRank(final String key, final int start, final int end) { public void zremrangeByRank(final String key, final int start, final int end) {
zremrangeByRank(SafeEncoder.encode(key), start, end); zremrangeByRank(SafeEncoder.encode(key), start, end);
@@ -468,8 +504,13 @@ public class Client extends BinaryClient implements Commands {
public void zremrangeByScore(final String key, final double start, public void zremrangeByScore(final String key, final double start,
final double end) { final double end) {
zremrangeByScore(SafeEncoder.encode(key), start, end); zremrangeByScore(SafeEncoder.encode(key), toByteArray(start), toByteArray(end));
} }
public void zremrangeByScore(final String key, final String start,
final String end) {
zremrangeByScore(SafeEncoder.encode(key), SafeEncoder.encode(start), SafeEncoder.encode(end));
}
public void zunionstore(final String dstkey, final String... sets) { public void zunionstore(final String dstkey, final String... sets) {
final byte[][] bsets = new byte[sets.length][]; final byte[][] bsets = new byte[sets.length][];

View File

@@ -183,6 +183,8 @@ public interface Commands {
final int timeout); final int timeout);
public void zcount(final String key, final double min, final double max); public void zcount(final String key, final double min, final double max);
public void zcount(final String key, final String min, final String max);
public void zrangeByScore(final String key, final double min, public void zrangeByScore(final String key, final double min,
final double max); final double max);
@@ -199,7 +201,13 @@ public interface Commands {
public void zrangeByScoreWithScores(final String key, final double min, public void zrangeByScoreWithScores(final String key, final double min,
final double max, final int offset, final int count); final double max, final int offset, final int count);
public void zrevrangeByScore(final String key, final double max, public void zrangeByScoreWithScores(final String key, final String min,
final String max);
public void zrangeByScoreWithScores(final String key, final String min,
final String max, final int offset, final int count);
public void zrevrangeByScore(final String key, final double max,
final double min); final double min);
public void zrevrangeByScore(final String key, final String max, public void zrevrangeByScore(final String key, final String max,
@@ -213,12 +221,21 @@ public interface Commands {
public void zrevrangeByScoreWithScores(final String key, final double max, public void zrevrangeByScoreWithScores(final String key, final double max,
final double min, final int offset, final int count); final double min, final int offset, final int count);
public void zrevrangeByScoreWithScores(final String key, final String max,
final String min);
public void zrevrangeByScoreWithScores(final String key, final String max,
final String min, final int offset, final int count);
public void zremrangeByRank(final String key, final int start, final int end); public void zremrangeByRank(final String key, final int start, final int end);
public void zremrangeByScore(final String key, final double start, public void zremrangeByScore(final String key, final double start,
final double end); final double end);
public void zremrangeByScore(final String key, final String start,
final String end);
public void zunionstore(final String dstkey, final String... sets); public void zunionstore(final String dstkey, final String... sets);
public void zunionstore(final String dstkey, final ZParams params, public void zunionstore(final String dstkey, final ZParams params,

View File

@@ -1991,6 +1991,12 @@ public class Jedis extends BinaryJedis implements JedisCommands {
client.zcount(key, min, max); client.zcount(key, min, max);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public Long zcount(final String key, final String min, final String max) {
checkIsInMulti();
client.zcount(key, min, max);
return client.getIntegerReply();
}
/** /**
* Return the all the elements in the sorted set at key with a score between * Return the all the elements in the sorted set at key with a score between
@@ -2125,6 +2131,13 @@ public class Jedis extends BinaryJedis implements JedisCommands {
client.zrangeByScore(key, min, max, offset, count); client.zrangeByScore(key, min, max, offset, count);
return new LinkedHashSet<String>(client.getMultiBulkReply()); return new LinkedHashSet<String>(client.getMultiBulkReply());
} }
public Set<String> zrangeByScore(final String key, final String min,
final String max, final int offset, final int count) {
checkIsInMulti();
client.zrangeByScore(key, min, max, offset, count);
return new LinkedHashSet<String>(client.getMultiBulkReply());
}
/** /**
* Return the all the elements in the sorted set at key with a score between * Return the all the elements in the sorted set at key with a score between
@@ -2189,6 +2202,14 @@ public class Jedis extends BinaryJedis implements JedisCommands {
Set<Tuple> set = getTupledSet(); Set<Tuple> set = getTupledSet();
return set; return set;
} }
public Set<Tuple> zrangeByScoreWithScores(final String key,
final String min, final String max) {
checkIsInMulti();
client.zrangeByScoreWithScores(key, min, max);
Set<Tuple> set = getTupledSet();
return set;
}
/** /**
* Return the all the elements in the sorted set at key with a score between * Return the all the elements in the sorted set at key with a score between
@@ -2254,6 +2275,15 @@ public class Jedis extends BinaryJedis implements JedisCommands {
Set<Tuple> set = getTupledSet(); Set<Tuple> set = getTupledSet();
return set; return set;
} }
public Set<Tuple> zrangeByScoreWithScores(final String key,
final String min, final String max, final int offset,
final int count) {
checkIsInMulti();
client.zrangeByScoreWithScores(key, min, max, offset, count);
Set<Tuple> set = getTupledSet();
return set;
}
private Set<Tuple> getTupledSet() { private Set<Tuple> getTupledSet() {
checkIsInMulti(); checkIsInMulti();
@@ -2303,6 +2333,30 @@ public class Jedis extends BinaryJedis implements JedisCommands {
Set<Tuple> set = getTupledSet(); Set<Tuple> set = getTupledSet();
return set; return set;
} }
public Set<Tuple> zrevrangeByScoreWithScores(final String key,
final String max, final String min, final int offset,
final int count) {
checkIsInMulti();
client.zrevrangeByScoreWithScores(key, max, min, offset, count);
Set<Tuple> set = getTupledSet();
return set;
}
public Set<String> zrevrangeByScore(final String key, final String max,
final String min, final int offset, final int count) {
checkIsInMulti();
client.zrevrangeByScore(key, max, min, offset, count);
return new LinkedHashSet<String>(client.getMultiBulkReply());
}
public Set<Tuple> zrevrangeByScoreWithScores(final String key,
final String max, final String min) {
checkIsInMulti();
client.zrevrangeByScoreWithScores(key, max, min);
Set<Tuple> set = getTupledSet();
return set;
}
/** /**
* Remove all elements in the sorted set at key with rank between start and * Remove all elements in the sorted set at key with rank between start and
@@ -2343,6 +2397,13 @@ public class Jedis extends BinaryJedis implements JedisCommands {
client.zremrangeByScore(key, start, end); client.zremrangeByScore(key, start, end);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public Long zremrangeByScore(final String key, final String start,
final String end) {
checkIsInMulti();
client.zremrangeByScore(key, start, end);
return client.getIntegerReply();
}
/** /**
* Creates a union or intersection of N sorted sets given by keys k1 through * Creates a union or intersection of N sorted sets given by keys k1 through

View File

@@ -136,13 +136,22 @@ public interface JedisCommands {
Long zcount(String key, double min, double max); Long zcount(String key, double min, double max);
Long zcount(String key, String min, String max);
Set<String> zrangeByScore(String key, double min, double max); Set<String> zrangeByScore(String key, double min, double max);
Set<String> zrangeByScore(String key, String min, String max);
Set<String> zrevrangeByScore(String key, double max, double min); Set<String> zrevrangeByScore(String key, double max, double min);
Set<String> zrangeByScore(String key, double min, double max, int offset, Set<String> zrangeByScore(String key, double min, double max, int offset,
int count); int count);
Set<String> zrevrangeByScore(String key, String max, String min);
Set<String> zrangeByScore(String key, String min, String max, int offset,
int count);
Set<String> zrevrangeByScore(String key, double max, double min, Set<String> zrevrangeByScore(String key, double max, double min,
int offset, int count); int offset, int count);
@@ -152,13 +161,28 @@ public interface JedisCommands {
Set<Tuple> zrangeByScoreWithScores(String key, double min, double max, Set<Tuple> zrangeByScoreWithScores(String key, double min, double max,
int offset, int count); int offset, int count);
Set<String> zrevrangeByScore(String key, String max, String min,
int offset, int count);
Set<Tuple> zrangeByScoreWithScores(String key, String min, String max);
Set<Tuple> zrevrangeByScoreWithScores(String key, String max, String min);
Set<Tuple> zrangeByScoreWithScores(String key, String min, String max,
int offset, int count);
Set<Tuple> zrevrangeByScoreWithScores(String key, double max, double min, Set<Tuple> zrevrangeByScoreWithScores(String key, double max, double min,
int offset, int count); int offset, int count);
Set<Tuple> zrevrangeByScoreWithScores(String key, String max, String min,
int offset, int count);
Long zremrangeByRank(String key, int start, int end); Long zremrangeByRank(String key, int start, int end);
Long zremrangeByScore(String key, double start, double end); Long zremrangeByScore(String key, double start, double end);
Long zremrangeByScore(String key, String start, String end);
Long linsert(String key, Client.LIST_POSITION where, String pivot, Long linsert(String key, Client.LIST_POSITION where, String pivot,
String value); String value);

View File

@@ -1,5 +1,6 @@
package redis.clients.jedis; package redis.clients.jedis;
import static redis.clients.jedis.Protocol.toByteArray;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -842,7 +843,7 @@ public class Pipeline extends Queable {
} }
public Response<Long> zcount(byte[] key, double min, double max) { public Response<Long> zcount(byte[] key, double min, double max) {
client.zcount(key, min, max); client.zcount(key, toByteArray(min), toByteArray(max));
return getResponse(BuilderFactory.LONG); return getResponse(BuilderFactory.LONG);
} }
@@ -896,10 +897,9 @@ public class Pipeline extends Queable {
public Response<Set<String>> zrangeByScore(byte[] key, double min, public Response<Set<String>> zrangeByScore(byte[] key, double min,
double max) { double max) {
client.zrangeByScore(key, min, max); return zrangeByScore(key, toByteArray(min), toByteArray(max));
return getResponse(BuilderFactory.STRING_ZSET);
} }
public Response<Set<String>> zrangeByScore(String key, String min, public Response<Set<String>> zrangeByScore(String key, String min,
String max) { String max) {
client.zrangeByScore(key, min, max); client.zrangeByScore(key, min, max);
@@ -920,6 +920,11 @@ public class Pipeline extends Queable {
public Response<Set<String>> zrangeByScore(byte[] key, double min, public Response<Set<String>> zrangeByScore(byte[] key, double min,
double max, int offset, int count) { double max, int offset, int count) {
return zrangeByScore(key, toByteArray(min), toByteArray(max), offset, count);
}
public Response<Set<String>> zrangeByScore(byte[] key, byte[] min,
byte[] max, int offset, int count) {
client.zrangeByScore(key, min, max, offset, count); client.zrangeByScore(key, min, max, offset, count);
return getResponse(BuilderFactory.STRING_ZSET); return getResponse(BuilderFactory.STRING_ZSET);
} }
@@ -932,6 +937,11 @@ public class Pipeline extends Queable {
public Response<Set<Tuple>> zrangeByScoreWithScores(byte[] key, double min, public Response<Set<Tuple>> zrangeByScoreWithScores(byte[] key, double min,
double max) { double max) {
return zrangeByScoreWithScores(key, toByteArray(min), toByteArray(max));
}
public Response<Set<Tuple>> zrangeByScoreWithScores(byte[] key, byte[] min,
byte[] max) {
client.zrangeByScoreWithScores(key, min, max); client.zrangeByScoreWithScores(key, min, max);
return getResponse(BuilderFactory.TUPLE_ZSET); return getResponse(BuilderFactory.TUPLE_ZSET);
} }
@@ -944,6 +954,12 @@ public class Pipeline extends Queable {
public Response<Set<Tuple>> zrangeByScoreWithScores(byte[] key, double min, public Response<Set<Tuple>> zrangeByScoreWithScores(byte[] key, double min,
double max, int offset, int count) { double max, int offset, int count) {
client.zrangeByScoreWithScores(key, toByteArray(min), toByteArray(max), offset, count);
return getResponse(BuilderFactory.TUPLE_ZSET);
}
public Response<Set<Tuple>> zrangeByScoreWithScores(byte[] key, byte[] min,
byte[] max, int offset, int count) {
client.zrangeByScoreWithScores(key, min, max, offset, count); client.zrangeByScoreWithScores(key, min, max, offset, count);
return getResponse(BuilderFactory.TUPLE_ZSET); return getResponse(BuilderFactory.TUPLE_ZSET);
} }
@@ -956,7 +972,7 @@ public class Pipeline extends Queable {
public Response<Set<String>> zrevrangeByScore(byte[] key, double max, public Response<Set<String>> zrevrangeByScore(byte[] key, double max,
double min) { double min) {
client.zrevrangeByScore(key, max, min); client.zrevrangeByScore(key, toByteArray(max), toByteArray(min));
return getResponse(BuilderFactory.STRING_ZSET); return getResponse(BuilderFactory.STRING_ZSET);
} }
@@ -980,6 +996,12 @@ public class Pipeline extends Queable {
public Response<Set<String>> zrevrangeByScore(byte[] key, double max, public Response<Set<String>> zrevrangeByScore(byte[] key, double max,
double min, int offset, int count) { double min, int offset, int count) {
client.zrevrangeByScore(key, toByteArray(max), toByteArray(min), offset, count);
return getResponse(BuilderFactory.STRING_ZSET);
}
public Response<Set<String>> zrevrangeByScore(byte[] key, byte[] max,
byte[] min, int offset, int count) {
client.zrevrangeByScore(key, max, min, offset, count); client.zrevrangeByScore(key, max, min, offset, count);
return getResponse(BuilderFactory.STRING_ZSET); return getResponse(BuilderFactory.STRING_ZSET);
} }
@@ -992,6 +1014,12 @@ public class Pipeline extends Queable {
public Response<Set<Tuple>> zrevrangeByScoreWithScores(byte[] key, public Response<Set<Tuple>> zrevrangeByScoreWithScores(byte[] key,
double max, double min) { double max, double min) {
client.zrevrangeByScoreWithScores(key, toByteArray(max), toByteArray(min));
return getResponse(BuilderFactory.TUPLE_ZSET);
}
public Response<Set<Tuple>> zrevrangeByScoreWithScores(byte[] key,
byte[] max, byte[] min) {
client.zrevrangeByScoreWithScores(key, max, min); client.zrevrangeByScoreWithScores(key, max, min);
return getResponse(BuilderFactory.TUPLE_ZSET); return getResponse(BuilderFactory.TUPLE_ZSET);
} }
@@ -1004,6 +1032,12 @@ public class Pipeline extends Queable {
public Response<Set<Tuple>> zrevrangeByScoreWithScores(byte[] key, public Response<Set<Tuple>> zrevrangeByScoreWithScores(byte[] key,
double max, double min, int offset, int count) { double max, double min, int offset, int count) {
client.zrevrangeByScoreWithScores(key, toByteArray(max), toByteArray(min), offset, count);
return getResponse(BuilderFactory.TUPLE_ZSET);
}
public Response<Set<Tuple>> zrevrangeByScoreWithScores(byte[] key,
byte[] max, byte[] min, int offset, int count) {
client.zrevrangeByScoreWithScores(key, max, min, offset, count); client.zrevrangeByScoreWithScores(key, max, min, offset, count);
return getResponse(BuilderFactory.TUPLE_ZSET); return getResponse(BuilderFactory.TUPLE_ZSET);
} }
@@ -1054,6 +1088,11 @@ public class Pipeline extends Queable {
} }
public Response<Long> zremrangeByScore(byte[] key, double start, double end) { public Response<Long> zremrangeByScore(byte[] key, double start, double end) {
client.zremrangeByScore(key, toByteArray(start), toByteArray(end));
return getResponse(BuilderFactory.LONG);
}
public Response<Long> zremrangeByScore(byte[] key, byte[] start, byte[] end) {
client.zremrangeByScore(key, start, end); client.zremrangeByScore(key, start, end);
return getResponse(BuilderFactory.LONG); return getResponse(BuilderFactory.LONG);
} }

View File

@@ -357,6 +357,11 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.zcount(key, min, max); return j.zcount(key, min, max);
} }
public Long zcount(String key, String min, String max) {
Jedis j = getShard(key);
return j.zcount(key, min, max);
}
public Set<String> zrangeByScore(String key, double min, double max) { public Set<String> zrangeByScore(String key, double min, double max) {
Jedis j = getShard(key); Jedis j = getShard(key);
@@ -402,6 +407,51 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.zrevrangeByScoreWithScores(key, max, min, offset, count); return j.zrevrangeByScoreWithScores(key, max, min, offset, count);
} }
public Set<String> zrangeByScore(String key, String min, String max) {
Jedis j = getShard(key);
return j.zrangeByScore(key, min, max);
}
public Set<String> zrevrangeByScore(String key, String max, String min) {
Jedis j = getShard(key);
return j.zrevrangeByScore(key, max, min);
}
public Set<String> zrangeByScore(String key, String min, String max,
int offset, int count) {
Jedis j = getShard(key);
return j.zrangeByScore(key, min, max, offset, count);
}
public Set<String> zrevrangeByScore(String key, String max, String min,
int offset, int count) {
Jedis j = getShard(key);
return j.zrevrangeByScore(key, max, min, offset, count);
}
public Set<Tuple> zrangeByScoreWithScores(String key, String min, String max) {
Jedis j = getShard(key);
return j.zrangeByScoreWithScores(key, min, max);
}
public Set<Tuple> zrevrangeByScoreWithScores(String key, String max,
String min) {
Jedis j = getShard(key);
return j.zrevrangeByScoreWithScores(key, max, min);
}
public Set<Tuple> zrangeByScoreWithScores(String key, String min,
String max, int offset, int count) {
Jedis j = getShard(key);
return j.zrangeByScoreWithScores(key, min, max, offset, count);
}
public Set<Tuple> zrevrangeByScoreWithScores(String key, String max,
String min, int offset, int count) {
Jedis j = getShard(key);
return j.zrevrangeByScoreWithScores(key, max, min, offset, count);
}
public Long zremrangeByRank(String key, int start, int end) { public Long zremrangeByRank(String key, int start, int end) {
Jedis j = getShard(key); Jedis j = getShard(key);
@@ -412,6 +462,11 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.zremrangeByScore(key, start, end); return j.zremrangeByScore(key, start, end);
} }
public Long zremrangeByScore(String key, String start, String end) {
Jedis j = getShard(key);
return j.zremrangeByScore(key, start, end);
}
public Long linsert(String key, LIST_POSITION where, String pivot, public Long linsert(String key, LIST_POSITION where, String pivot,
String value) { String value) {

View File

@@ -373,6 +373,10 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
assertEquals(2, result); assertEquals(2, result);
result = jedis.zcount("foo", "(0.01", "+inf");
assertEquals(3, result);
// Binary // Binary
jedis.zadd(bfoo, 1d, ba); jedis.zadd(bfoo, 1d, ba);
jedis.zadd(bfoo, 10d, bb); jedis.zadd(bfoo, 10d, bb);
@@ -383,6 +387,9 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
assertEquals(2, bresult); assertEquals(2, bresult);
bresult = jedis.zcount(bfoo, SafeEncoder.encode("(0.01"), SafeEncoder.encode("+inf"));
assertEquals(3, bresult);
} }
@Test @Test
@@ -655,7 +662,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
assertEquals(bexpected, brange); assertEquals(bexpected, brange);
} }
@Test @Test
public void zremrangeByRank() { public void zremrangeByRank() {
jedis.zadd("foo", 1d, "a"); jedis.zadd("foo", 1d, "a");