Java Code Examples for org.redisson.api.RSortedSet#remove()

The following examples show how to use org.redisson.api.RSortedSet#remove() . 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: RankMatchMgr.java    From Almost-Famous with MIT License 6 votes vote down vote up
@Override
public void remove(Actor actor, MatchEnum reason) {
    if (actor.getBattleMode() != BattleModeEnum.RANK)
        return;
    String match_queue_key = KeyPrefix.BattleRedisPrefix.MATCH_RANK_MODE_QUEUE + this.generatorKey(actor.getBattleRankBean().getRankId());
    try {
        RedissonUtils.lock(redissonClient, match_queue_key);
        RSortedSet<SimpleActor> sortedSet = redissonClient.getSortedSet(match_queue_key);
        SimpleActor simpleActor = new SimpleActor(actor.getRid(), actor.getSchoolLevel(), actor.getMatchBeginTime());
        sortedSet.remove(simpleActor);
        if (log.isDebugEnabled()) {
            log.debug("从段位模式匹配队列中移出玩家role={}, reason={}", actor.getRid(), reason);
        }
    } finally {
        RedissonUtils.unlock(redissonClient, match_queue_key);
    }
}
 
Example 2
Source File: SortedSetExamples.java    From redisson-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    // connects to 127.0.0.1:6379 by default
    RedissonClient redisson = Redisson.create();
    
    RSortedSet<String> sortedSet = redisson.getSortedSet("mySortedSet");
    sortedSet.add("1");
    sortedSet.add("2");
    sortedSet.add("3");
    
    for (String string : sortedSet) {
        // iteration through bulk loaded values
    }
    
    String firstValue = sortedSet.first();
    String lastValue = sortedSet.last();
    
    boolean removedValue = sortedSet.remove("1");
    sortedSet.removeAll(Arrays.asList("1", "2", "3"));
    sortedSet.containsAll(Arrays.asList("4", "1", "0"));
    
    redisson.shutdown();
}
 
Example 3
Source File: RedissonSortedSetTest.java    From redisson with Apache License 2.0 4 votes vote down vote up
public void testTailSet() {
    RSortedSet<Integer> set = redisson.getSortedSet("set");

    set.add(1);
    set.add(2);
    set.add(3);
    set.add(4);
    set.add(5);

    SortedSet<Integer> hs = set.tailSet(3);
    hs.add(10);

    assertThat(hs).containsExactly(3, 4, 5, 10);

    set.remove(4);

    assertThat(hs).containsExactly(3, 5, 10);

    set.remove(3);

    assertThat(hs).containsExactly(5, 10);

    hs.add(-1);
}
 
Example 4
Source File: RedissonSortedSetTest.java    From redisson with Apache License 2.0 4 votes vote down vote up
public void testHeadSet() {
    RSortedSet<Integer> set = redisson.getSortedSet("set");

    set.add(1);
    set.add(2);
    set.add(3);
    set.add(4);
    set.add(5);

    SortedSet<Integer> hs = set.headSet(3);
    hs.add(0);

    assertThat(hs).containsExactly(0, 1, 2);

    set.remove(2);

    assertThat(hs).containsExactly(0, 1);

    set.remove(3);

    assertThat(hs).containsExactly(0, 1);

    hs.add(7);
}
 
Example 5
Source File: RedissonScoredSortedSetTest.java    From redisson with Apache License 2.0 4 votes vote down vote up
public void testTailSet() {
    RSortedSet<Integer> set = redisson.getSortedSet("set");

    set.add(1);
    set.add(2);
    set.add(3);
    set.add(4);
    set.add(5);

    SortedSet<Integer> hs = set.tailSet(3);
    hs.add(10);

    assertThat(hs).containsExactly(3, 4, 5, 10);

    set.remove(4);

    assertThat(hs).containsExactly(3, 5, 10);

    set.remove(3);

    assertThat(hs).containsExactly(5, 10);

    hs.add(-1);
}
 
Example 6
Source File: RedissonScoredSortedSetTest.java    From redisson with Apache License 2.0 4 votes vote down vote up
public void testHeadSet() {
    RSortedSet<Integer> set = redisson.getSortedSet("set");

    set.add(1);
    set.add(2);
    set.add(3);
    set.add(4);
    set.add(5);

    SortedSet<Integer> hs = set.headSet(3);
    hs.add(0);

    assertThat(hs).containsExactly(0, 1, 2);

    set.remove(2);

    assertThat(hs).containsExactly(0, 1);

    set.remove(3);

    assertThat(hs).containsExactly(0, 1);

    hs.add(7);
}