org.redisson.api.RSetMultimapCache Java Examples

The following examples show how to use org.redisson.api.RSetMultimapCache. 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: SetMultimapCacheExamples.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();
    
    RSetMultimapCache<String, Integer> multimap = redisson.getSetMultimapCache("myMultimap");
    multimap.put("1", 1);
    multimap.put("1", 2);
    multimap.put("1", 3);
    multimap.put("2", 5);
    multimap.put("2", 6);
    multimap.put("4", 7);
    
    // set ttl = 10 seconds 
    multimap.expireKey("1", 10, TimeUnit.SECONDS);
    
    RSet<Integer> values1 = multimap.get("1");
    RSet<Integer> values2 = multimap.get("2");
    
    boolean hasEntry = multimap.containsEntry("1", 3);
    Collection<Entry<String, Integer>> entries = multimap.entries();
    Collection<Integer> values = multimap.values();
    
    boolean isRemoved = multimap.remove("1", 3);
    Set<Integer> removedValues = multimap.removeAll("1");
    
    Collection<? extends Integer> newValues = Arrays.asList(5, 6, 7, 8, 9);
    boolean isNewKey = multimap.putAll("5", newValues);
    
    Set<Integer> oldValues = multimap.replaceValues("2", newValues);
    Set<Integer> allValues = multimap.getAll("2");

    long keysRemoved = multimap.fastRemove("2", "32");
    
    redisson.shutdown();
}
 
Example #2
Source File: TracingRSetMultimapCache.java    From java-redis-client with Apache License 2.0 4 votes vote down vote up
public TracingRSetMultimapCache(RSetMultimapCache<K, V> cache,
    TracingRedissonHelper tracingRedissonHelper) {
  super(cache, tracingRedissonHelper);
  this.cache = cache;
  this.tracingRedissonHelper = tracingRedissonHelper;
}
 
Example #3
Source File: TracingRedissonClient.java    From java-redis-client with Apache License 2.0 4 votes vote down vote up
@Override
public <K, V> RSetMultimapCache<K, V> getSetMultimapCache(String name) {
  return new TracingRSetMultimapCache<>(redissonClient.getSetMultimapCache(name),
      tracingRedissonHelper);
}
 
Example #4
Source File: TracingRedissonClient.java    From java-redis-client with Apache License 2.0 4 votes vote down vote up
@Override
public <K, V> RSetMultimapCache<K, V> getSetMultimapCache(String name,
    Codec codec) {
  return new TracingRSetMultimapCache<>(redissonClient.getSetMultimapCache(name, codec),
      tracingRedissonHelper);
}