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

The following examples show how to use org.redisson.api.RSet#readAll() . 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: RedissonSessionRepository.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Override
public Map<String, RedissonSession> findByIndexNameAndIndexValue(String indexName, String indexValue) {
    if (!PRINCIPAL_NAME_INDEX_NAME.equals(indexName)) {
        return Collections.emptyMap();
    }
    
    RSet<String> set = getPrincipalSet(indexValue);
    
    Set<String> sessionIds = set.readAll();
    Map<String, RedissonSession> result = new HashMap<String, RedissonSession>();
    for (String id : sessionIds) {
        RedissonSession session = findById(id);
        if (session != null) {
            result.put(id, session);
        }
    }
    return result;
}
 
Example 2
Source File: SetCacheExamples.java    From redisson-examples with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
    // connects to 127.0.0.1:6379 by default
    RedissonClient redisson = Redisson.create();
    
    RSetCache<String> setCache = redisson.getSetCache("mySet");

    // with ttl = 20 seconds
    boolean isAdded = setCache.add("1", 20, TimeUnit.SECONDS);
    // store value permanently
    setCache.add("2");
    
    setCache.contains("1");
    
    for (String string : setCache) {
        // iteration through bulk loaded values
    }
    
    boolean removedValue = setCache.remove("1");
    setCache.removeAll(Arrays.asList("1", "2", "3"));
    setCache.containsAll(Arrays.asList("4", "1", "0"));
    
    RSet<String> secondsSet = redisson.getSet("mySecondsSet");
    secondsSet.add("4");
    secondsSet.add("5");

    Set<String> allValues = secondsSet.readAll();
    
    redisson.shutdown();
}
 
Example 3
Source File: SetExamples.java    From redisson-examples with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
    // connects to 127.0.0.1:6379 by default
    RedissonClient redisson = Redisson.create();
    
    RSet<String> set = redisson.getSet("mySet");
    set.add("1");
    set.add("2");
    set.add("3");
    
    set.contains("1");
    
    for (String string : set) {
        // iteration through bulk loaded values
    }
    
    boolean removedValue = set.remove("1");
    set.removeAll(Arrays.asList("1", "2", "3"));
    set.containsAll(Arrays.asList("4", "1", "0"));
    
    String randomRemovedValue = set.removeRandom();
    String randomValue = set.random();

    RSet<String> secondsSet = redisson.getSet("mySecondsSet");
    secondsSet.add("4");
    secondsSet.add("5");

    // union with "mySecondsSet" and write it
    set.union(secondsSet.getName());
    // union with "mySecondsSet" without change of set
    set.readUnion(secondsSet.getName());
    
    // diff with "mySecondsSet" and write it
    set.diff(secondsSet.getName());
    // diff with "mySecondsSet" without change of set
    set.readDiff(secondsSet.getName());
    
    // intersect with "mySecondsSet" and write it
    set.intersection(secondsSet.getName());
    // intersect with "mySecondsSet" without change of set
    set.readIntersection(secondsSet.getName());
    
    Set<String> allValues = set.readAll();
    
    redisson.shutdown();
}