RLexSortedSet.readAll, pollFirst, pollLast, first, last and revRank methods added

pull/485/head
Nikita 9 years ago
parent 0cc9c73e1d
commit 62d4e85d2a

@ -20,6 +20,24 @@ import java.util.Set;
public interface RLexSortedSet extends RLexSortedSetAsync, Set<String>, RExpirable { public interface RLexSortedSet extends RLexSortedSetAsync, Set<String>, RExpirable {
String pollFirst();
String pollLast();
String first();
String last();
/**
* Returns rank of value, with the scores ordered from high to low.
*
* @param o
* @return rank or <code>null</code> if value does not exist
*/
Integer revRank(String o);
Collection<String> readAll();
int removeRangeTail(String fromElement, boolean fromInclusive); int removeRangeTail(String fromElement, boolean fromInclusive);
/** /**

@ -21,6 +21,16 @@ import io.netty.util.concurrent.Future;
public interface RLexSortedSetAsync extends RCollectionAsync<String> { public interface RLexSortedSetAsync extends RCollectionAsync<String> {
Future<String> pollLastAsync();
Future<String> pollFirstAsync();
Future<String> firstAsync();
Future<String> lastAsync();
Future<Collection<String>> readAllAsync();
Future<Integer> removeRangeAsync(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive); Future<Integer> removeRangeAsync(String fromElement, boolean fromInclusive, String toElement, boolean toInclusive);
/** /**
@ -126,5 +136,13 @@ public interface RLexSortedSetAsync extends RCollectionAsync<String> {
*/ */
@Deprecated @Deprecated
Future<Collection<String>> valueRangeAsync(int startIndex, int endIndex); Future<Collection<String>> valueRangeAsync(int startIndex, int endIndex);
/**
* Returns rank of value, with the scores ordered from high to low.
*
* @param o
* @return rank or <code>null</code> if value does not exist
*/
Future<Integer> revRankAsync(String o);
} }

@ -1,12 +1,53 @@
package org.redisson; package org.redisson;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.assertThat;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.redisson.core.RLexSortedSet; import org.redisson.core.RLexSortedSet;
public class RedissonLexSortedSetTest extends BaseTest { public class RedissonLexSortedSetTest extends BaseTest {
@Test
public void testPollLast() {
RLexSortedSet set = redisson.getLexSortedSet("simple");
Assert.assertNull(set.pollLast());
set.add("a");
set.add("b");
set.add("c");
Assert.assertEquals("c", set.pollLast());
MatcherAssert.assertThat(set, Matchers.contains("a", "b"));
}
@Test
public void testPollFirst() {
RLexSortedSet set = redisson.getLexSortedSet("simple");
Assert.assertNull(set.pollFirst());
set.add("a");
set.add("b");
set.add("c");
Assert.assertEquals("a", set.pollFirst());
MatcherAssert.assertThat(set, Matchers.contains("b", "c"));
}
@Test
public void testFirstLast() {
RLexSortedSet set = redisson.getLexSortedSet("simple");
set.add("a");
set.add("b");
set.add("c");
set.add("d");
Assert.assertEquals("a", set.first());
Assert.assertEquals("d", set.last());
}
@Test @Test
public void testRemoveLexRangeTail() { public void testRemoveLexRangeTail() {
RLexSortedSet set = redisson.getLexSortedSet("simple"); RLexSortedSet set = redisson.getLexSortedSet("simple");

Loading…
Cancel
Save