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

The following examples show how to use org.redisson.api.RScoredSortedSet#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: RedissonScoredSortedSetTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testSortOrderByPattern() {
    RScoredSortedSet<Integer> set = redisson.getScoredSortedSet("list", IntegerCodec.INSTANCE);
    set.add(10, 1);
    set.add(9, 2);
    set.add(8, 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 = set.readSort("test*", SortOrder.DESC);
    assertThat(descSort).containsExactly(1, 2, 3);

    Set<Integer> ascSort = set.readSort("test*", SortOrder.ASC);
    assertThat(ascSort).containsExactly(3, 2, 1);
}
 
Example 2
Source File: RedissonScoredSortedSetTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testSortOrderByPatternLimit() {
    RScoredSortedSet<Integer> set = redisson.getScoredSortedSet("list", IntegerCodec.INSTANCE);
    set.add(10, 1);
    set.add(9, 2);
    set.add(8, 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 = set.readSort("test*", SortOrder.DESC, 1, 2);
    assertThat(descSort).containsExactly(2, 3);

    Set<Integer> ascSort = set.readSort("test*", SortOrder.ASC, 1, 2);
    assertThat(ascSort).containsExactly(2, 1);
}
 
Example 3
Source File: RedissonScoredSortedSetTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testSortOrderByPatternGet() {
    RScoredSortedSet<Integer> set = redisson.getScoredSortedSet("list", StringCodec.INSTANCE);
    set.add(10, 1);
    set.add(9, 2);
    set.add(8, 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 = set.readSort("test*", Arrays.asList("tester*"), SortOrder.DESC);
    assertThat(descSort).containsExactly("obj3", "obj2", "obj1");

    Collection<String> ascSort = set.readSort("test*", Arrays.asList("tester*"), SortOrder.ASC);
    assertThat(ascSort).containsExactly("obj1", "obj2", "obj3");
}
 
Example 4
Source File: RedissonScoredSortedSetTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testSortOrderByPatternGetLimit() {
    RScoredSortedSet<Integer> set = redisson.getScoredSortedSet("list", StringCodec.INSTANCE);
    set.add(10, 1);
    set.add(9, 2);
    set.add(8, 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 = set.readSort("test*", Arrays.asList("tester*"), SortOrder.DESC, 1, 2);
    assertThat(descSort).containsExactly("obj2", "obj1");

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

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

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