Java Code Examples for org.redisson.api.RSet#readSort()

The following examples show how to use org.redisson.api.RSet#readSort() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedissonSetTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testSortOrderByPattern() {
    RSet<Integer> list = redisson.getSet("list", IntegerCodec.INSTANCE);
    list.add(1);
    list.add(2);
    list.add(3);
    
    redisson.getBucket("test1", IntegerCodec.INSTANCE).set(3);
    redisson.getBucket("test2", IntegerCodec.INSTANCE).set(2);
    redisson.getBucket("test3", IntegerCodec.INSTANCE).set(1);
    
    Set<Integer> descSort = list.readSort("test*", SortOrder.DESC);
    assertThat(descSort).containsExactly(1, 2, 3);

    Set<Integer> ascSort = list.readSort("test*", SortOrder.ASC);
    assertThat(ascSort).containsExactly(3, 2, 1);
}
 
Example 2
Source File: RedissonSetTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testSortOrderByPatternLimit() {
    RSet<Integer> list = redisson.getSet("list", IntegerCodec.INSTANCE);
    list.add(1);
    list.add(2);
    list.add(3);
    
    redisson.getBucket("test1", IntegerCodec.INSTANCE).set(3);
    redisson.getBucket("test2", IntegerCodec.INSTANCE).set(2);
    redisson.getBucket("test3", IntegerCodec.INSTANCE).set(1);
    
    Set<Integer> descSort = list.readSort("test*", SortOrder.DESC, 1, 2);
    assertThat(descSort).containsExactly(2, 3);

    Set<Integer> ascSort = list.readSort("test*", SortOrder.ASC, 1, 2);
    assertThat(ascSort).containsExactly(2, 1);
}
 
Example 3
Source File: RedissonSetTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testSortOrderByPatternGet() {
    RSet<String> list = redisson.getSet("list", StringCodec.INSTANCE);
    list.add("1");
    list.add("2");
    list.add("3");
    
    redisson.getBucket("test1", IntegerCodec.INSTANCE).set(1);
    redisson.getBucket("test2", IntegerCodec.INSTANCE).set(2);
    redisson.getBucket("test3", IntegerCodec.INSTANCE).set(3);
    
    redisson.getBucket("tester1", StringCodec.INSTANCE).set("obj1");
    redisson.getBucket("tester2", StringCodec.INSTANCE).set("obj2");
    redisson.getBucket("tester3", StringCodec.INSTANCE).set("obj3");
    
    Collection<String> descSort = list.readSort("test*", Arrays.asList("tester*"), SortOrder.DESC);
    assertThat(descSort).containsExactly("obj3", "obj2", "obj1");

    Collection<String> ascSort = list.readSort("test*", Arrays.asList("tester*"), SortOrder.ASC);
    assertThat(ascSort).containsExactly("obj1", "obj2", "obj3");
}
 
Example 4
Source File: RedissonSetTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testSortOrderByPatternGetLimit() {
    RSet<String> list = redisson.getSet("list", StringCodec.INSTANCE);
    list.add("1");
    list.add("2");
    list.add("3");
    
    redisson.getBucket("test1", IntegerCodec.INSTANCE).set(1);
    redisson.getBucket("test2", IntegerCodec.INSTANCE).set(2);
    redisson.getBucket("test3", IntegerCodec.INSTANCE).set(3);
    
    redisson.getBucket("tester1", StringCodec.INSTANCE).set("obj1");
    redisson.getBucket("tester2", StringCodec.INSTANCE).set("obj2");
    redisson.getBucket("tester3", StringCodec.INSTANCE).set("obj3");
    
    Collection<String> descSort = list.readSort("test*", Arrays.asList("tester*"), SortOrder.DESC, 1, 2);
    assertThat(descSort).containsExactly("obj2", "obj1");

    Collection<String> ascSort = list.readSort("test*", Arrays.asList("tester*"), SortOrder.ASC, 1, 2);
    assertThat(ascSort).containsExactly("obj2", "obj3");
}
 
Example 5
Source File: RedissonSetTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testSortOrder() {
    RSet<Integer> list = redisson.getSet("list", IntegerCodec.INSTANCE);
    list.add(1);
    list.add(2);
    list.add(3);
    
    Set<Integer> descSort = list.readSort(SortOrder.DESC);
    assertThat(descSort).containsExactly(3, 2, 1);

    Set<Integer> ascSort = list.readSort(SortOrder.ASC);
    assertThat(ascSort).containsExactly(1, 2, 3);
}
 
Example 6
Source File: RedissonSetTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testSortOrderLimit() {
    RSet<Integer> list = redisson.getSet("list", IntegerCodec.INSTANCE);
    list.add(1);
    list.add(2);
    list.add(3);
    
    Set<Integer> descSort = list.readSort(SortOrder.DESC, 1, 2);
    assertThat(descSort).containsExactly(2, 1);

    Set<Integer> ascSort = list.readSort(SortOrder.ASC, 1, 2);
    assertThat(ascSort).containsExactly(2, 3);
}