Added support for ZCOUNT

This commit is contained in:
Jonathan Leibiusky
2010-08-07 18:04:06 -03:00
parent a842e64f8a
commit 2279746489
3 changed files with 21 additions and 0 deletions

View File

@@ -435,4 +435,8 @@ public class Client extends Connection {
public void punsubscribe(String... patterns) {
sendCommand("PUNSUBSCRIBE", patterns);
}
public void zcount(String key, double min, double max) {
sendCommand("ZCOUNT", key, String.valueOf(min), String.valueOf(max));
}
}

View File

@@ -545,4 +545,9 @@ public class Jedis {
public void psubscribe(JedisPubSub jedisPubSub, String... patterns) {
jedisPubSub.proceedWithPatterns(client, patterns);
}
public int zcount(String key, double min, double max) {
client.zcount(key, min, max);
return client.getIntegerReply();
}
}

View File

@@ -180,4 +180,16 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
score = jedis.zscore("foo", "c");
assertEquals(0.1d, score);
}
@Test
public void zcount() {
jedis.zadd("foo", 1d, "a");
jedis.zadd("foo", 10d, "b");
jedis.zadd("foo", 0.1d, "c");
jedis.zadd("foo", 2d, "a");
int result = jedis.zcount("foo", 0.01d, 2.1d);
assertEquals(2, result);
}
}