Java Code Examples for org.redisson.api.RSetCache#removeAll()

The following examples show how to use org.redisson.api.RSetCache#removeAll() . 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: RedissonTransactionalSetCacheTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testRemoveAll() {
    RSetCache<String> s = redisson.getSetCache("test");
    s.add("1");
    s.add("3");
    
    RTransaction t = redisson.createTransaction(TransactionOptions.defaults());
    RSetCache<String> set = t.getSetCache("test");
    Set<String> putSet = new HashSet<String>();
    putSet.add("4");
    putSet.add("3");
    set.removeAll(putSet);
    assertThat(s).containsOnly("1", "3");
    assertThat(set).containsOnly("1");
    
    t.commit();
    
    assertThat(s).containsOnly("1");
}
 
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();
}