diff --git a/README.md b/README.md index f14e591..fa315f4 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Jedis is a WORK IN PROGRESS. - Sharding - Persistence control commands - Remote server control commands -- The ZREMRANGEBYSCORE, ZUNIONSTORE, ZINTERSTORE commands +- The ZUNIONSTORE, ZINTERSTORE commands But stay close because things are going fast and all this will be implemented soon! @@ -22,7 +22,7 @@ But stay close because things are going fast and all this will be implemented so - Commands operating on hashes - Commands operating on lists - Commands operating on sets -- Commands operating on sorted sets (not ZREMRANGEBYSCORE, ZUNIONSTORE, ZINTERSTORE) +- Commands operating on sorted sets (not ZUNIONSTORE, ZINTERSTORE) - Transactions - Pipelining - Publish/Subscribe diff --git a/src/main/java/redis/clients/jedis/Client.java b/src/main/java/redis/clients/jedis/Client.java index f08449d..998843d 100644 --- a/src/main/java/redis/clients/jedis/Client.java +++ b/src/main/java/redis/clients/jedis/Client.java @@ -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)); + } } diff --git a/src/main/java/redis/clients/jedis/Jedis.java b/src/main/java/redis/clients/jedis/Jedis.java index 1456415..ecb05d2 100644 --- a/src/main/java/redis/clients/jedis/Jedis.java +++ b/src/main/java/redis/clients/jedis/Jedis.java @@ -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(); + } } \ No newline at end of file diff --git a/src/test/java/redis/clients/jedis/tests/commands/SortedSetCommandsTest.java b/src/test/java/redis/clients/jedis/tests/commands/SortedSetCommandsTest.java index 05aecf5..2f1f117 100644 --- a/src/test/java/redis/clients/jedis/tests/commands/SortedSetCommandsTest.java +++ b/src/test/java/redis/clients/jedis/tests/commands/SortedSetCommandsTest.java @@ -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 expected = new LinkedHashSet(); + expected.add("b"); + + assertEquals(expected, jedis.zrange("foo", 0, 100)); + } } \ No newline at end of file