ZREMRANGEBYRANK support added #143

pull/255/head
Nikita 10 years ago
parent 1bfc3a7a13
commit 55c8534d8f

@ -59,6 +59,14 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
return get(removeAsync(object));
}
public int removeRangeByRank(int startIndex, int endIndex) {
return get(removeRangeByRankAsync(startIndex, endIndex));
}
public Future<Integer> removeRangeByRankAsync(int startIndex, int endIndex) {
return commandExecutor.readAsync(getName(), codec, RedisCommands.ZREMRANGEBYRANK, getName(), startIndex, endIndex);
}
@Override
public void clear() {
delete();

@ -56,6 +56,7 @@ public interface RedisCommands {
RedisStrictCommand<Double> ZSCORE = new RedisStrictCommand<Double>("ZSCORE", new DoubleReplayConvertor());
RedisCommand<Integer> ZRANK = new RedisCommand<Integer>("ZRANK", new IntegerReplayConvertor(), 2);
RedisCommand<List<Object>> ZRANGE = new RedisCommand<List<Object>>("ZRANGE", new ObjectListReplayDecoder<Object>());
RedisStrictCommand<Integer> ZREMRANGEBYRANK = new RedisStrictCommand<Integer>("ZREMRANGEBYRANK", new IntegerReplayConvertor());
RedisCommand<List<Object>> ZRANGEBYLEX = new RedisCommand<List<Object>>("ZRANGEBYLEX", new ObjectListReplayDecoder<Object>());
RedisCommand<List<ScoredEntry<Object>>> ZRANGE_ENTRY = new RedisCommand<List<ScoredEntry<Object>>>("ZRANGE", new ScoredSortedSetReplayDecoder<Object>());
RedisCommand<ListScanResult<Object>> ZSCAN = new RedisCommand<ListScanResult<Object>>("ZSCAN", new NestedMultiDecoder(new ObjectListReplayDecoder<Object>(), new ScoredSortedSetScanReplayDecoder()), ValueType.OBJECT);

@ -21,6 +21,8 @@ import org.redisson.client.protocol.ScoredEntry;
public interface RScoredSortedSet<V> extends RScoredSortedSetAsync<V>, Iterable<V>, RExpirable {
int removeRangeByRank(int startIndex, int endIndex);
Integer rank(V o);
Double getScore(V o);

@ -23,6 +23,8 @@ import io.netty.util.concurrent.Future;
public interface RScoredSortedSetAsync<V> extends RExpirableAsync {
Future<Integer> removeRangeByRankAsync(int startIndex, int endIndex);
Future<Integer> rankAsync(V o);
Future<Double> getScoreAsync(V o);

@ -21,6 +21,21 @@ import io.netty.util.concurrent.Future;
public class RedissonScoredSortedSetTest extends BaseTest {
@Test
public void testRemoveRangeByRank() {
RScoredSortedSet<String> set = redisson.getScoredSortedSet("simple");
set.add(0.1, "a");
set.add(0.2, "b");
set.add(0.3, "c");
set.add(0.4, "d");
set.add(0.5, "e");
set.add(0.6, "f");
set.add(0.7, "g");
Assert.assertEquals(2, set.removeRangeByRank(0, 1));
MatcherAssert.assertThat(set, Matchers.contains("c", "d", "e", "f", "g"));
}
@Test
public void testRank() {
RScoredSortedSet<String> set = redisson.getScoredSortedSet("simple");

Loading…
Cancel
Save