Implemented ZREMRANGEBYRANK

This commit is contained in:
Jonathan Leibiusky
2010-08-07 18:34:42 -03:00
parent 111eb11440
commit bb54328802
4 changed files with 30 additions and 2 deletions

View File

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

View File

@@ -463,4 +463,9 @@ public class Client extends Connection {
.valueOf(max), "LIMIT", String.valueOf(offset), String
.valueOf(count), "WITHSCORES");
}
public void zremrangeByRank(String key, int start, int end) {
sendCommand("ZREMRANGEBYRANK", key, String.valueOf(start), String
.valueOf(end));
}
}

View File

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

View File

@@ -252,4 +252,22 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
assertEquals(expected, range);
}
@Test
public void zremrangeByRank() {
jedis.zadd("foo", 1d, "a");
jedis.zadd("foo", 10d, "b");
jedis.zadd("foo", 0.1d, "c");
jedis.zadd("foo", 2d, "a");
int result = jedis.zremrangeByRank("foo", 0, 0);
assertEquals(1, result);
Set<String> expected = new LinkedHashSet<String>();
expected.add("a");
expected.add("b");
assertEquals(expected, jedis.zrange("foo", 0, 100));
}
}