revRank and revRankAsync methods added. #433

pull/442/head^2
Nikita 9 years ago
parent ecfd2502a1
commit 2ca0f2d008

@ -480,4 +480,14 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
return commandExecutor.readAsync(getName(), codec, RedisCommands.ZRANGEBYSCORE_ENTRY, getName(), startValue, endValue, "WITHSCORES", "LIMIT", offset, count);
}
@Override
public Future<Integer> revRankAsync(V o) {
return commandExecutor.readAsync(getName(), codec, RedisCommands.ZREVRANK_INT, getName(), o);
}
@Override
public int revRank(V o) {
return get(revRankAsync(o));
}
}

@ -83,6 +83,7 @@ public interface RedisCommands {
RedisCommand<Boolean> ZSCORE_CONTAINS = new RedisCommand<Boolean>("ZSCORE", new BooleanNotNullReplayConvertor(), 2);
RedisStrictCommand<Double> ZSCORE = new RedisStrictCommand<Double>("ZSCORE", new DoubleReplayConvertor(), 2);
RedisCommand<Integer> ZRANK_INT = new RedisCommand<Integer>("ZRANK", new IntegerReplayConvertor(), 2);
RedisCommand<Integer> ZREVRANK_INT = new RedisCommand<Integer>("ZREVRANK", new IntegerReplayConvertor(), 2);
RedisStrictCommand<Long> ZRANK = new RedisStrictCommand<Long>("ZRANK", 2);
RedisCommand<Object> ZRANGE_SINGLE = new RedisCommand<Object>("ZRANGE", new ObjectFirstResultReplayDecoder<Object>());
RedisCommand<List<Object>> ZRANGE = new RedisCommand<List<Object>>("ZRANGE", new ObjectListReplayDecoder<Object>());

@ -38,6 +38,8 @@ public interface RScoredSortedSet<V> extends RScoredSortedSetAsync<V>, Iterable<
int rank(V o);
int revRank(V o);
Double getScore(V o);
/**

@ -40,6 +40,8 @@ public interface RScoredSortedSetAsync<V> extends RExpirableAsync {
Future<Integer> rankAsync(V o);
Future<Integer> revRankAsync(V o);
Future<Double> getScoreAsync(V o);
/**

@ -162,6 +162,21 @@ public class RedissonScoredSortedSetTest extends BaseTest {
Assert.assertEquals(3, (int)set.rank("d"));
}
@Test
public void testRevRank() {
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(1, (int)set.revRank("f"));
}
@Test
public void testAddAsync() throws InterruptedException, ExecutionException {
RScoredSortedSet<Integer> set = redisson.getScoredSortedSet("simple");

Loading…
Cancel
Save