Search in sources :

Example 1 with RLexSortedSet

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

the class RedissonScoredSortedSetTest method testLexSortedSet.

@Test
public void testLexSortedSet() {
    RLexSortedSet set = redisson.getLexSortedSet("simple");
    set.add("a");
    set.add("b");
    set.add("c");
    set.add("d");
    set.add("e");
    Collection<String> r = set.range("b", true, "e", false, 1, 2);
    String[] a = r.toArray(new String[0]);
    Assert.assertArrayEquals(new String[] { "c", "d" }, a);
}
Also used : RLexSortedSet(org.redisson.api.RLexSortedSet) Test(org.junit.Test)

Example 2 with RLexSortedSet

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

the class RedissonLexSortedSetTest method testLexRange.

@Test
public void testLexRange() {
    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.range("aaa", true, "g", false)).containsExactly("b", "c", "d", "e", "f");
    assertThat(set.range("aaa", true, "g", false, 2, 3)).containsExactly("d", "e", "f");
}
Also used : RLexSortedSet(org.redisson.api.RLexSortedSet) Test(org.junit.jupiter.api.Test)

Example 3 with RLexSortedSet

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

the class RedissonLexSortedSetTest method testAll.

@Test
public void testAll() {
    RLexSortedSet set = redisson.getLexSortedSet("simple");
    set.addAll(Arrays.asList("foo", "bar"));
    assertThat(set.contains("foo")).isTrue();
    assertThat(set.contains("bar")).isTrue();
    assertThat(set.contains("123")).isFalse();
}
Also used : RLexSortedSet(org.redisson.api.RLexSortedSet) Test(org.junit.jupiter.api.Test)

Example 4 with RLexSortedSet

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

the class RedissonLexSortedSetTest method testLexRangeTail.

@Test
public void testLexRangeTail() {
    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"));
    assertThat(set.rangeTail("c", false)).containsExactly("d", "e", "f", "g");
    assertThat(set.rangeTail("c", true)).containsExactly("c", "d", "e", "f", "g");
    assertThat(set.rangeTail("c", false, 1, 2)).containsExactly("e", "f");
    assertThat(set.rangeTail("c", true, 1, 3)).containsExactly("d", "e", "f");
}
Also used : RLexSortedSet(org.redisson.api.RLexSortedSet) Test(org.junit.jupiter.api.Test)

Example 5 with RLexSortedSet

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

the class RedissonLexSortedSetTest method testLexRangeHeadReversed.

@Test
public void testLexRangeHeadReversed() {
    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.rangeHeadReversed("c", false)).containsExactly("b", "a");
    assertThat(set.rangeHeadReversed("c", true)).containsExactly("c", "b", "a");
    assertThat(set.rangeHeadReversed("c", false, 1, 1)).containsExactly("a");
    assertThat(set.rangeHeadReversed("c", true, 1, 2)).containsExactly("b", "a");
}
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