Support Sorted Set with LEX commands

* new commands : ZLEXCOUNT, ZRANGEBYLEX, ZREMRANGEBYLEX
** added commands to Jedis, ShardedJedis, JedisCluster, PipelineBase with Binary
/ Normal(String)
** description links
*** http://redis.io/commands/zlexcount
*** http://redis.io/commands/zrangebylex
*** http://redis.io/commands/zremrangebylex
** Unit test included
This commit is contained in:
Jungtaek Lim
2014-04-22 23:39:37 +09:00
parent ac53759f97
commit 409740f06c
14 changed files with 396 additions and 2 deletions

View File

@@ -16,6 +16,7 @@ import static redis.clients.jedis.Protocol.Keyword.WITHSCORES;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.Map.Entry; import java.util.Map.Entry;
import redis.clients.jedis.Protocol.Command; import redis.clients.jedis.Protocol.Command;
@@ -828,6 +829,25 @@ public class BinaryClient extends Connection {
sendCommand(ZINTERSTORE, args.toArray(new byte[args.size()][])); sendCommand(ZINTERSTORE, args.toArray(new byte[args.size()][]));
} }
public void zlexcount(final byte[] key, final byte[] min, final byte[] max) {
sendCommand(ZLEXCOUNT, key, min, max);
}
public void zrangeByLex(final byte[] key, final byte[] min, final byte[] max) {
sendCommand(ZRANGEBYLEX, key, min, max);
}
public void zrangeByLex(final byte[] key, final byte[] min, final byte[] max,
final int offset, final int count) {
sendCommand(ZRANGEBYLEX, key, min, max, LIMIT.raw,
toByteArray(offset), toByteArray(count));
}
public void zremrangeByLex(byte[] key, byte[] min, byte[] max) {
sendCommand(ZREMRANGEBYLEX, key, min, max);
}
public void save() { public void save() {
sendCommand(SAVE); sendCommand(SAVE);
} }

View File

@@ -2732,6 +2732,35 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
return client.getIntegerReply(); return client.getIntegerReply();
} }
@Override
public Long zlexcount(final byte[] key, final byte[] min, final byte[] max) {
checkIsInMulti();
client.zlexcount(key, min, max);
return client.getIntegerReply();
}
@Override
public Set<byte[]> zrangeByLex(final byte[] key, final byte[] min, final byte[] max) {
checkIsInMulti();
client.zrangeByLex(key, min, max);
return new LinkedHashSet<byte[]>(client.getBinaryMultiBulkReply());
}
@Override
public Set<byte[]> zrangeByLex(final byte[] key, final byte[] min, final byte[] max,
final int offset, final int count) {
checkIsInMulti();
client.zrangeByLex(key, min, max, offset, count);
return new LinkedHashSet<byte[]>(client.getBinaryMultiBulkReply());
}
@Override
public Long zremrangeByLex(final byte[] key, final byte[] min, final byte[] max) {
checkIsInMulti();
client.zremrangeByLex(key, min, max);
return client.getIntegerReply();
}
/** /**
* Synchronously save the DB on disk. * Synchronously save the DB on disk.
* <p> * <p>

View File

@@ -191,6 +191,15 @@ public interface BinaryJedisCommands {
Long zremrangeByScore(byte[] key, byte[] start, byte[] end); Long zremrangeByScore(byte[] key, byte[] start, byte[] end);
Long zlexcount(final byte[] key, final byte[] min, final byte[] max);
Set<byte[]> zrangeByLex(final byte[] key, final byte[] min, final byte[] max);
Set<byte[]> zrangeByLex(final byte[] key, final byte[] min, final byte[] max,
int offset, int count);
Long zremrangeByLex(final byte[] key, final byte[] min, final byte[] max);
Long linsert(byte[] key, Client.LIST_POSITION where, byte[] pivot, Long linsert(byte[] key, Client.LIST_POSITION where, byte[] pivot,
byte[] value); byte[] value);

View File

@@ -207,6 +207,15 @@ public interface BinaryRedisPipeline {
Response<Double> zscore(byte[] key, byte[] member); Response<Double> zscore(byte[] key, byte[] member);
Response<Long> zlexcount(final byte[] key, final byte[] min, final byte[] max);
Response<Set<byte[]>> zrangeByLex(final byte[] key, final byte[] max, final byte[] min);
Response<Set<byte[]>> zrangeByLex(final byte[] key, final byte[] max, final byte[] min,
int offset, int count);
Response<Long> zremrangeByLex(final byte[] key, final byte[] min, final byte[] max);
Response<Long> bitcount(byte[] key); Response<Long> bitcount(byte[] key);
Response<Long> bitcount(byte[] key, long start, long end); Response<Long> bitcount(byte[] key, long start, long end);

View File

@@ -475,6 +475,31 @@ public class BinaryShardedJedis extends Sharded<Jedis, JedisShardInfo>
return j.zremrangeByScore(key, start, end); return j.zremrangeByScore(key, start, end);
} }
@Override
public Long zlexcount(final byte[] key, final byte[] min, final byte[] max) {
Jedis j = getShard(key);
return j.zlexcount(key, min, max);
}
@Override
public Set<byte[]> zrangeByLex(final byte[] key, final byte[] min, final byte[] max) {
Jedis j = getShard(key);
return j.zrangeByLex(key, min, max);
}
@Override
public Set<byte[]> zrangeByLex(final byte[] key, final byte[] min, final byte[] max,
final int offset, final int count) {
Jedis j = getShard(key);
return j.zrangeByLex(key, min, max, offset, count);
}
@Override
public Long zremrangeByLex(final byte[] key, final byte[] min, final byte[] max) {
Jedis j = getShard(key);
return j.zremrangeByLex(key, min, max);
}
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);
@@ -569,4 +594,5 @@ public class BinaryShardedJedis extends Sharded<Jedis, JedisShardInfo>
Jedis j = getShard(key); Jedis j = getShard(key);
return j.bitcount(key, start, end); return j.bitcount(key, start, end);
} }
} }

View File

@@ -586,6 +586,24 @@ public class Client extends BinaryClient implements Commands {
zinterstore(SafeEncoder.encode(dstkey), params, bsets); zinterstore(SafeEncoder.encode(dstkey), params, bsets);
} }
public void zlexcount(final String key, final String min, final String max) {
zlexcount(SafeEncoder.encode(key), SafeEncoder.encode(min), SafeEncoder.encode(max));
}
public void zrangeByLex(final String key, final String min, final String max) {
zrangeByLex(SafeEncoder.encode(key), SafeEncoder.encode(min), SafeEncoder.encode(max));
}
public void zrangeByLex(final String key, final String min, final String max,
final int offset, final int count) {
zrangeByLex(SafeEncoder.encode(key), SafeEncoder.encode(min), SafeEncoder.encode(max),
offset, count);
}
public void zremrangeByLex(final String key, final String min, final String max) {
zremrangeByLex(SafeEncoder.encode(key), SafeEncoder.encode(min), SafeEncoder.encode(max));
}
public void strlen(final String key) { public void strlen(final String key) {
strlen(SafeEncoder.encode(key)); strlen(SafeEncoder.encode(key));
} }

View File

@@ -2562,6 +2562,35 @@ public class Jedis extends BinaryJedis implements JedisCommands,
return client.getIntegerReply(); return client.getIntegerReply();
} }
@Override
public Long zlexcount(final String key, final String min, final String max) {
checkIsInMulti();
client.zlexcount(key, min, max);
return client.getIntegerReply();
}
@Override
public Set<String> zrangeByLex(final String key, final String min, final String max) {
checkIsInMulti();
client.zrangeByLex(key, min, max);
return new LinkedHashSet<String>(client.getMultiBulkReply());
}
@Override
public Set<String> zrangeByLex(final String key, final String min, final String max,
final int offset, final int count) {
checkIsInMulti();
client.zrangeByLex(key, min, max, offset, count);
return new LinkedHashSet<String>(client.getMultiBulkReply());
}
@Override
public Long zremrangeByLex(final String key, final String min, final String max) {
checkIsInMulti();
client.zremrangeByLex(key, min, max);
return client.getIntegerReply();
}
public Long strlen(final String key) { public Long strlen(final String key) {
client.strlen(key); client.strlen(key);
return client.getIntegerReply(); return client.getIntegerReply();
@@ -3412,4 +3441,5 @@ public class Jedis extends BinaryJedis implements JedisCommands,
return BuilderFactory.STRING_MAP return BuilderFactory.STRING_MAP
.build(client.getBinaryMultiBulkReply()); .build(client.getBinaryMultiBulkReply());
} }
} }

View File

@@ -1064,6 +1064,51 @@ public class JedisCluster implements JedisCommands, BasicCommands {
}.run(key); }.run(key);
} }
@Override
public Long zlexcount(final String key, final String min, final String max) {
return new JedisClusterCommand<Long>(connectionHandler, timeout,
maxRedirections) {
@Override
public Long execute(Jedis connection) {
return connection.zlexcount(key, min, max);
}
}.run(key);
}
@Override
public Set<String> zrangeByLex(final String key, final String min, final String max) {
return new JedisClusterCommand<Set<String>>(connectionHandler, timeout,
maxRedirections) {
@Override
public Set<String> execute(Jedis connection) {
return connection.zrangeByLex(key, min, max);
}
}.run(key);
}
@Override
public Set<String> zrangeByLex(final String key, final String min, final String max,
final int offset, final int count) {
return new JedisClusterCommand<Set<String>>(connectionHandler, timeout,
maxRedirections) {
@Override
public Set<String> execute(Jedis connection) {
return connection.zrangeByLex(key, min, max, offset, count);
}
}.run(key);
}
@Override
public Long zremrangeByLex(final String key, final String min, final String max) {
return new JedisClusterCommand<Long>(connectionHandler, timeout,
maxRedirections) {
@Override
public Long execute(Jedis connection) {
return connection.zremrangeByLex(key, min, max);
}
}.run(key);
}
@Override @Override
public Long linsert(final String key, final LIST_POSITION where, public Long linsert(final String key, final LIST_POSITION where,
final String pivot, final String value) { final String pivot, final String value) {
@@ -1481,4 +1526,5 @@ public class JedisCluster implements JedisCommands, BasicCommands {
} }
}.run(null); }.run(null);
} }
} }

View File

@@ -190,6 +190,15 @@ public interface JedisCommands {
Long zremrangeByScore(String key, String start, String end); Long zremrangeByScore(String key, String start, String end);
Long zlexcount(final String key, final String min, final String max);
Set<String> zrangeByLex(final String key, final String min, final String max);
Set<String> zrangeByLex(final String key, final String min, final String max,
final int offset, final int count);
Long zremrangeByLex(final String key, final String min, final String max);
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

@@ -1008,6 +1008,56 @@ abstract class PipelineBase extends Queable implements BinaryRedisPipeline,
return getResponse(BuilderFactory.DOUBLE); return getResponse(BuilderFactory.DOUBLE);
} }
@Override
public Response<Long> zlexcount(final byte[] key, final byte[] min, final byte[] max) {
getClient(key).zlexcount(key, min, max);
return getResponse(BuilderFactory.LONG);
}
@Override
public Response<Long> zlexcount(final String key, final String min, final String max) {
getClient(key).zlexcount(key, min, max);
return getResponse(BuilderFactory.LONG);
}
@Override
public Response<Set<byte[]>> zrangeByLex(final byte[] key, final byte[] max, final byte[] min) {
getClient(key).zrangeByLex(key, min, max);
return getResponse(BuilderFactory.BYTE_ARRAY_ZSET);
}
@Override
public Response<Set<String>> zrangeByLex(final String key, final String max, final String min) {
getClient(key).zrangeByLex(key, min, max);
return getResponse(BuilderFactory.STRING_ZSET);
}
@Override
public Response<Set<byte[]>> zrangeByLex(final byte[] key, final byte[] max,
final byte[] min, final int offset, final int count) {
getClient(key).zrangeByLex(key, min, max, offset, count);
return getResponse(BuilderFactory.BYTE_ARRAY_ZSET);
}
@Override
public Response<Set<String>> zrangeByLex(final String key, final String max,
final String min, final int offset, final int count) {
getClient(key).zrangeByLex(key, min, max, offset, count);
return getResponse(BuilderFactory.STRING_ZSET);
}
@Override
public Response<Long> zremrangeByLex(final byte[] key, final byte[] min, final byte[] max) {
getClient(key).zremrangeByLex(key, min, max);
return getResponse(BuilderFactory.LONG);
}
@Override
public Response<Long> zremrangeByLex(final String key, final String min, final String max) {
getClient(key).zremrangeByLex(key, min, max);
return getResponse(BuilderFactory.LONG);
}
public Response<Long> bitcount(String key) { public Response<Long> bitcount(String key) {
getClient(key).bitcount(key); getClient(key).bitcount(key);
return getResponse(BuilderFactory.LONG); return getResponse(BuilderFactory.LONG);

View File

@@ -208,7 +208,7 @@ public final class Protocol {
} }
public static enum Command { public static enum Command {
PING, SET, GET, QUIT, EXISTS, DEL, TYPE, FLUSHDB, KEYS, RANDOMKEY, RENAME, RENAMENX, RENAMEX, DBSIZE, EXPIRE, EXPIREAT, TTL, SELECT, MOVE, FLUSHALL, GETSET, MGET, SETNX, SETEX, MSET, MSETNX, DECRBY, DECR, INCRBY, INCR, APPEND, SUBSTR, HSET, HGET, HSETNX, HMSET, HMGET, HINCRBY, HEXISTS, HDEL, HLEN, HKEYS, HVALS, HGETALL, RPUSH, LPUSH, LLEN, LRANGE, LTRIM, LINDEX, LSET, LREM, LPOP, RPOP, RPOPLPUSH, SADD, SMEMBERS, SREM, SPOP, SMOVE, SCARD, SISMEMBER, SINTER, SINTERSTORE, SUNION, SUNIONSTORE, SDIFF, SDIFFSTORE, SRANDMEMBER, ZADD, ZRANGE, ZREM, ZINCRBY, ZRANK, ZREVRANK, ZREVRANGE, ZCARD, ZSCORE, MULTI, DISCARD, EXEC, WATCH, UNWATCH, SORT, BLPOP, BRPOP, AUTH, SUBSCRIBE, PUBLISH, UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, PUBSUB, ZCOUNT, ZRANGEBYSCORE, ZREVRANGEBYSCORE, ZREMRANGEBYRANK, ZREMRANGEBYSCORE, ZUNIONSTORE, ZINTERSTORE, SAVE, BGSAVE, BGREWRITEAOF, LASTSAVE, SHUTDOWN, INFO, MONITOR, SLAVEOF, CONFIG, STRLEN, SYNC, LPUSHX, PERSIST, RPUSHX, ECHO, LINSERT, DEBUG, BRPOPLPUSH, SETBIT, GETBIT, SETRANGE, GETRANGE, EVAL, EVALSHA, SCRIPT, SLOWLOG, OBJECT, BITCOUNT, BITOP, SENTINEL, DUMP, RESTORE, PEXPIRE, PEXPIREAT, PTTL, INCRBYFLOAT, PSETEX, CLIENT, TIME, MIGRATE, HINCRBYFLOAT, SCAN, HSCAN, SSCAN, ZSCAN, WAIT, CLUSTER, ASKING; PING, SET, GET, QUIT, EXISTS, DEL, TYPE, FLUSHDB, KEYS, RANDOMKEY, RENAME, RENAMENX, RENAMEX, DBSIZE, EXPIRE, EXPIREAT, TTL, SELECT, MOVE, FLUSHALL, GETSET, MGET, SETNX, SETEX, MSET, MSETNX, DECRBY, DECR, INCRBY, INCR, APPEND, SUBSTR, HSET, HGET, HSETNX, HMSET, HMGET, HINCRBY, HEXISTS, HDEL, HLEN, HKEYS, HVALS, HGETALL, RPUSH, LPUSH, LLEN, LRANGE, LTRIM, LINDEX, LSET, LREM, LPOP, RPOP, RPOPLPUSH, SADD, SMEMBERS, SREM, SPOP, SMOVE, SCARD, SISMEMBER, SINTER, SINTERSTORE, SUNION, SUNIONSTORE, SDIFF, SDIFFSTORE, SRANDMEMBER, ZADD, ZRANGE, ZREM, ZINCRBY, ZRANK, ZREVRANK, ZREVRANGE, ZCARD, ZSCORE, MULTI, DISCARD, EXEC, WATCH, UNWATCH, SORT, BLPOP, BRPOP, AUTH, SUBSCRIBE, PUBLISH, UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, PUBSUB, ZCOUNT, ZRANGEBYSCORE, ZREVRANGEBYSCORE, ZREMRANGEBYRANK, ZREMRANGEBYSCORE, ZUNIONSTORE, ZINTERSTORE, ZLEXCOUNT, ZRANGEBYLEX, ZREMRANGEBYLEX, SAVE, BGSAVE, BGREWRITEAOF, LASTSAVE, SHUTDOWN, INFO, MONITOR, SLAVEOF, CONFIG, STRLEN, SYNC, LPUSHX, PERSIST, RPUSHX, ECHO, LINSERT, DEBUG, BRPOPLPUSH, SETBIT, GETBIT, SETRANGE, GETRANGE, EVAL, EVALSHA, SCRIPT, SLOWLOG, OBJECT, BITCOUNT, BITOP, SENTINEL, DUMP, RESTORE, PEXPIRE, PEXPIREAT, PTTL, INCRBYFLOAT, PSETEX, CLIENT, TIME, MIGRATE, HINCRBYFLOAT, SCAN, HSCAN, SSCAN, ZSCAN, WAIT, CLUSTER, ASKING;
public final byte[] raw; public final byte[] raw;

View File

@@ -185,6 +185,15 @@ public interface RedisPipeline {
Response<Double> zscore(String key, String member); Response<Double> zscore(String key, String member);
Response<Long> zlexcount(final String key, final String min, final String max);
Response<Set<String>> zrangeByLex(final String key, final String max, final String min);
Response<Set<String>> zrangeByLex(final String key, final String max, final String min,
final int offset, final int count);
Response<Long> zremrangeByLex(final String key, final String start, final String end);
Response<Long> bitcount(String key); Response<Long> bitcount(String key);
Response<Long> bitcount(String key, long start, long end); Response<Long> bitcount(String key, long start, long end);

View File

@@ -507,6 +507,27 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands {
return j.zremrangeByScore(key, start, end); return j.zremrangeByScore(key, start, end);
} }
@Override
public Long zlexcount(final String key, final String min, final String max) {
return getShard(key).zlexcount(key, min, max);
}
@Override
public Set<String> zrangeByLex(final String key, final String min, final String max) {
return getShard(key).zrangeByLex(key, min, max);
}
@Override
public Set<String> zrangeByLex(final String key, final String min, final String max,
final int offset, final int count) {
return getShard(key).zrangeByLex(key, min, max, offset, count);
}
@Override
public Long zremrangeByLex(final String key, final String min, final String max) {
return getShard(key).zremrangeByLex(key, min, max);
}
public Long linsert(String key, LIST_POSITION where, String pivot, public Long linsert(String key, LIST_POSITION where, String pivot,
String value) { String value) {
Jedis j = getShard(key); Jedis j = getShard(key);
@@ -570,4 +591,5 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.zscan(key, cursor); return j.zscan(key, cursor);
} }
} }

View File

@@ -3,6 +3,8 @@ package redis.clients.jedis.tests.commands;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Set; import java.util.Set;
import javax.swing.text.html.MinimalHTMLWriter;
import org.junit.Test; import org.junit.Test;
import redis.clients.jedis.ScanParams; import redis.clients.jedis.ScanParams;
@@ -19,6 +21,10 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
final byte[] ba = { 0x0A }; final byte[] ba = { 0x0A };
final byte[] bb = { 0x0B }; final byte[] bb = { 0x0B };
final byte[] bc = { 0x0C }; final byte[] bc = { 0x0C };
final byte[] bInclusiveB = { 0x5B, 0x0B };
final byte[] bExclusiveC = { 0x28, 0x0C };
final byte[] bLexMinusInf = { 0x2D };
final byte[] bLexPlusInf = { 0x2B };
@Test @Test
public void zadd() { public void zadd() {
@@ -86,6 +92,48 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
} }
@Test
public void zrangeByLex() {
jedis.zadd("foo", 1, "aa");
jedis.zadd("foo", 1, "c");
jedis.zadd("foo", 1, "bb");
jedis.zadd("foo", 1, "d");
Set<String> expected = new LinkedHashSet<String>();
expected.add("bb");
expected.add("c");
// exclusive aa ~ inclusive c
assertEquals(expected, jedis.zrangeByLex("foo", "(aa", "[c"));
expected.clear();
expected.add("bb");
expected.add("c");
// with LIMIT
assertEquals(expected, jedis.zrangeByLex("foo", "-", "+", 1, 2));
}
@Test
public void zrangeByLexBinary() {
// binary
jedis.zadd(bfoo, 1, ba);
jedis.zadd(bfoo, 1, bc);
jedis.zadd(bfoo, 1, bb);
Set<byte[]> bExpected = new LinkedHashSet<byte[]>();
bExpected.add(bb);
assertEquals(bExpected, jedis.zrangeByLex(bfoo, bInclusiveB, bExclusiveC));
bExpected.clear();
bExpected.add(ba);
bExpected.add(bb);
// with LIMIT
assertEquals(bExpected, jedis.zrangeByLex(bfoo, bLexMinusInf, bLexPlusInf, 0, 2));
}
@Test @Test
public void zrevrange() { public void zrevrange() {
jedis.zadd("foo", 1d, "a"); jedis.zadd("foo", 1d, "a");
@@ -396,6 +444,40 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
assertEquals(3, bresult); assertEquals(3, bresult);
} }
@Test
public void zlexcount() {
jedis.zadd("foo", 1, "a");
jedis.zadd("foo", 1, "b");
jedis.zadd("foo", 1, "c");
jedis.zadd("foo", 1, "aa");
long result = jedis.zlexcount("foo", "[aa", "(c");
assertEquals(2, result);
result = jedis.zlexcount("foo", "-", "+");
assertEquals(4, result);
result = jedis.zlexcount("foo", "-", "(c");
assertEquals(3, result);
result = jedis.zlexcount("foo", "[aa", "+");
assertEquals(3, result);
}
@Test
public void zlexcountBinary() {
// Binary
jedis.zadd(bfoo, 1, ba);
jedis.zadd(bfoo, 1, bc);
jedis.zadd(bfoo, 1, bb);
long result = jedis.zlexcount(bfoo, bInclusiveB, bExclusiveC);
assertEquals(1, result);
result = jedis.zlexcount(bfoo, bLexMinusInf, bLexPlusInf);
assertEquals(3, result);
}
@Test @Test
public void zrangebyscore() { public void zrangebyscore() {
jedis.zadd("foo", 1d, "a"); jedis.zadd("foo", 1d, "a");
@@ -734,6 +816,41 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
assertEquals(bexpected, jedis.zrange(bfoo, 0, 100)); assertEquals(bexpected, jedis.zrange(bfoo, 0, 100));
} }
@Test
public void zremrangeByLex() {
jedis.zadd("foo", 1, "a");
jedis.zadd("foo", 1, "b");
jedis.zadd("foo", 1, "c");
jedis.zadd("foo", 1, "aa");
long result = jedis.zremrangeByLex("foo", "[aa", "(c");
assertEquals(2, result);
Set<String> expected = new LinkedHashSet<String>();
expected.add("a");
expected.add("c");
assertEquals(expected, jedis.zrangeByLex("foo", "-", "+"));
}
@Test
public void zremrangeByLexBinary() {
jedis.zadd(bfoo, 1, ba);
jedis.zadd(bfoo, 1, bc);
jedis.zadd(bfoo, 1, bb);
long bresult = jedis.zremrangeByLex(bfoo, bInclusiveB, bExclusiveC);
assertEquals(1, bresult);
Set<byte[]> bexpected = new LinkedHashSet<byte[]>();
bexpected.add(ba);
bexpected.add(bc);
assertEquals(bexpected, jedis.zrangeByLex(bfoo, bLexMinusInf, bLexPlusInf));
}
@Test @Test
public void zunionstore() { public void zunionstore() {
jedis.zadd("foo", 1, "a"); jedis.zadd("foo", 1, "a");