Implemented ZREMRANGEBYSCORE

This commit is contained in:
Jonathan Leibiusky
2010-08-07 19:37:16 -03:00
parent bb54328802
commit 84f4c45004
4 changed files with 29 additions and 2 deletions

View File

@@ -10,7 +10,7 @@ Jedis is a WORK IN PROGRESS.
- Sharding - Sharding
- Persistence control commands - Persistence control commands
- Remote server 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! 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 hashes
- Commands operating on lists - Commands operating on lists
- Commands operating on sets - Commands operating on sets
- Commands operating on sorted sets (not ZREMRANGEBYSCORE, ZUNIONSTORE, ZINTERSTORE) - Commands operating on sorted sets (not ZUNIONSTORE, ZINTERSTORE)
- Transactions - Transactions
- Pipelining - Pipelining
- Publish/Subscribe - Publish/Subscribe

View File

@@ -468,4 +468,9 @@ public class Client extends Connection {
sendCommand("ZREMRANGEBYRANK", key, String.valueOf(start), String sendCommand("ZREMRANGEBYRANK", key, String.valueOf(start), String
.valueOf(end)); .valueOf(end));
} }
public void zremrangeByScore(String key, int start, int end) {
sendCommand("ZREMRANGEBYSCORE", key, String.valueOf(start), String
.valueOf(end));
}
} }

View File

@@ -577,4 +577,9 @@ public class Jedis {
client.zremrangeByRank(key, start, end); client.zremrangeByRank(key, start, end);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int zremrangeByScore(String key, int start, int end) {
client.zremrangeByScore(key, start, end);
return client.getIntegerReply();
}
} }

View File

@@ -270,4 +270,21 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
assertEquals(expected, jedis.zrange("foo", 0, 100)); 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));
}
} }