Search in sources :

Example 11 with RLexSortedSet

use of org.redisson.api.RLexSortedSet in project redisson by redisson.

the class RedissonLexSortedSetTest method testRemoveLexRangeTail.

@Test
public void testRemoveLexRangeTail() {
    RLexSortedSet set = redisson.getLexSortedSet("simple");
    Assertions.assertTrue(set.add("a"));
    Assertions.assertFalse(set.add("a"));
    Assertions.assertTrue(set.add("b"));
    Assertions.assertTrue(set.add("c"));
    Assertions.assertTrue(set.add("d"));
    Assertions.assertTrue(set.add("e"));
    Assertions.assertTrue(set.add("f"));
    Assertions.assertTrue(set.add("g"));
    Assertions.assertEquals(0, (int) set.removeRangeTail("z", false));
    Assertions.assertEquals(4, (int) set.removeRangeTail("c", false));
    assertThat(set).containsExactly("a", "b", "c");
    Assertions.assertEquals(1, (int) set.removeRangeTail("c", true));
    assertThat(set).containsExactly("a", "b");
}
Also used : RLexSortedSet(org.redisson.api.RLexSortedSet) Test(org.junit.jupiter.api.Test)

Example 12 with RLexSortedSet

use of org.redisson.api.RLexSortedSet in project redisson by redisson.

the class RedissonLexSortedSetTest method testLexRangeReversed.

@Test
public void testLexRangeReversed() {
    RLexSortedSet set = redisson.getLexSortedSet("simple");
    set.add("a");
    set.add("b");
    set.add("c");
    set.add("d");
    set.add("e");
    set.add("f");
    set.add("g");
    assertThat(set.rangeReversed("aaa", true, "g", false)).containsExactly("f", "e", "d", "c", "b");
    assertThat(set.rangeReversed("aaa", true, "g", false, 1, 2)).containsExactly("e", "d");
}
Also used : RLexSortedSet(org.redisson.api.RLexSortedSet) Test(org.junit.jupiter.api.Test)

Example 13 with RLexSortedSet

use of org.redisson.api.RLexSortedSet in project redisson by redisson.

the class RedissonLexSortedSetTest method testFirstLast.

@Test
public void testFirstLast() {
    RLexSortedSet set = redisson.getLexSortedSet("simple");
    set.add("a");
    set.add("b");
    set.add("c");
    set.add("d");
    Assertions.assertEquals("a", set.first());
    Assertions.assertEquals("d", set.last());
}
Also used : RLexSortedSet(org.redisson.api.RLexSortedSet) Test(org.junit.jupiter.api.Test)

Example 14 with RLexSortedSet

use of org.redisson.api.RLexSortedSet in project redisson by redisson.

the class RedissonLexSortedSetTest method testLexCount.

@Test
public void testLexCount() {
    RLexSortedSet set = redisson.getLexSortedSet("simple");
    set.add("a");
    set.add("b");
    set.add("c");
    set.add("d");
    set.add("e");
    set.add("f");
    set.add("g");
    assertThat(set.count("b", true, "f", true)).isEqualTo(5);
    assertThat(set.count("b", false, "f", false)).isEqualTo(3);
}
Also used : RLexSortedSet(org.redisson.api.RLexSortedSet) Test(org.junit.jupiter.api.Test)

Example 15 with RLexSortedSet

use of org.redisson.api.RLexSortedSet in project redisson by redisson.

the class RedissonLexSortedSetTest method testPollLast.

@Test
public void testPollLast() {
    RLexSortedSet set = redisson.getLexSortedSet("simple");
    Assertions.assertNull(set.pollLast());
    set.add("a");
    set.add("b");
    set.add("c");
    Assertions.assertEquals("c", set.pollLast());
    assertThat(set).containsExactly("a", "b");
}
Also used : RLexSortedSet(org.redisson.api.RLexSortedSet) Test(org.junit.jupiter.api.Test)

Aggregations

RLexSortedSet (org.redisson.api.RLexSortedSet)17 Test (org.junit.jupiter.api.Test)15 List (java.util.List)1 Test (org.junit.Test)1 ScoredEntry (org.redisson.client.protocol.ScoredEntry)1