Implemented ZREMRANGEBYSCORE
This commit is contained in:
@@ -468,4 +468,9 @@ public class Client extends Connection {
|
||||
sendCommand("ZREMRANGEBYRANK", key, String.valueOf(start), String
|
||||
.valueOf(end));
|
||||
}
|
||||
|
||||
public void zremrangeByScore(String key, int start, int end) {
|
||||
sendCommand("ZREMRANGEBYSCORE", key, String.valueOf(start), String
|
||||
.valueOf(end));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -577,4 +577,9 @@ public class Jedis {
|
||||
client.zremrangeByRank(key, start, end);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int zremrangeByScore(String key, int start, int end) {
|
||||
client.zremrangeByScore(key, start, end);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
}
|
||||
@@ -270,4 +270,21 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
|
||||
assertEquals(expected, jedis.zrange("foo", 0, 100));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zremrangeByScore() {
|
||||
jedis.zadd("foo", 1d, "a");
|
||||
jedis.zadd("foo", 10d, "b");
|
||||
jedis.zadd("foo", 0.1d, "c");
|
||||
jedis.zadd("foo", 2d, "a");
|
||||
|
||||
int result = jedis.zremrangeByScore("foo", 0, 2);
|
||||
|
||||
assertEquals(2, result);
|
||||
|
||||
Set<String> expected = new LinkedHashSet<String>();
|
||||
expected.add("b");
|
||||
|
||||
assertEquals(expected, jedis.zrange("foo", 0, 100));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user