diff --git a/redisson/src/main/java/org/redisson/api/RBatchReactive.java b/redisson/src/main/java/org/redisson/api/RBatchReactive.java index fb7ed4cb1..6dee18b19 100644 --- a/redisson/src/main/java/org/redisson/api/RBatchReactive.java +++ b/redisson/src/main/java/org/redisson/api/RBatchReactive.java @@ -99,7 +99,32 @@ public interface RBatchReactive { * @return SetMultimap object */ RSetMultimapReactive getSetMultimap(String name, Codec codec); - + + /** + * Returns Set based Multimap cache instance by name. + * Supports key eviction by specifying a time to live. + * If eviction is not required then it's better to use regular set multimap {@link #getSetMultimap(String)}. + * + * @param type of key + * @param type of value + * @param name - name of object + * @return RSetMultimapCacheRx object + */ + RSetMultimapCacheReactive getSetMultimapCache(String name); + + /** + * Returns Set based Multimap cache instance by name using provided codec for both map keys and values. + * Supports key eviction by specifying a time to live. + * If eviction is not required then it's better to use regular set multimap {@link #getSetMultimap(String, Codec)}. + * + * @param type of key + * @param type of value + * @param name - name of object + * @param codec - codec for keys and values + * @return RSetMultimapCacheRx object + */ + RSetMultimapCacheReactive getSetMultimapCache(String name, Codec codec); + /** * Returns set-based cache instance by name. * Uses map (value_hash, value) under the hood for minimal memory consumption. @@ -318,7 +343,32 @@ public interface RBatchReactive { * @return ListMultimap object */ RListMultimapReactive getListMultimap(String name, Codec codec); - + + /** + * Returns List based Multimap cache instance by name. + * Supports key eviction by specifying a time to live. + * If eviction is not required then it's better to use regular list multimap {@link #getListMultimap(String)}. + * + * @param type of key + * @param type of value + * @param name - name of object + * @return RListMultimapCacheRx object + */ + RListMultimapReactive getListMultimapCache(String name); + + /** + * Returns List based Multimap cache instance by name using provided codec for both map keys and values. + * Supports key eviction by specifying a time to live. + * If eviction is not required then it's better to use regular list multimap {@link #getListMultimap(String, Codec)}. + * + * @param type of key + * @param type of value + * @param name - name of object + * @param codec - codec for keys and values + * @return RListMultimapCacheRx object + */ + RListMultimapReactive getListMultimapCache(String name, Codec codec); + /** * Returns map instance by name. * diff --git a/redisson/src/main/java/org/redisson/reactive/RedissonBatchReactive.java b/redisson/src/main/java/org/redisson/reactive/RedissonBatchReactive.java index 911541ea5..d0fb8ffeb 100644 --- a/redisson/src/main/java/org/redisson/reactive/RedissonBatchReactive.java +++ b/redisson/src/main/java/org/redisson/reactive/RedissonBatchReactive.java @@ -330,6 +330,20 @@ public class RedissonBatchReactive implements RBatchReactive { new RedissonSetMultimapReactive(codec, executorService, name, null), RSetMultimapReactive.class); } + @Override + public RSetMultimapCacheReactive getSetMultimapCache(String name) { + RSetMultimap map = new RedissonSetMultimapCache<>(evictionScheduler, executorService, name); + return ReactiveProxyBuilder.create(executorService, map, + new RedissonSetMultimapCacheReactive<>(map, executorService, null), RSetMultimapCacheReactive.class); + } + + @Override + public RSetMultimapCacheReactive getSetMultimapCache(String name, Codec codec) { + RSetMultimap map = new RedissonSetMultimapCache<>(evictionScheduler, codec, executorService, name); + return ReactiveProxyBuilder.create(executorService, map, + new RedissonSetMultimapCacheReactive<>(map, executorService, null), RSetMultimapCacheReactive.class); + } + @Override public RListMultimapReactive getListMultimap(String name) { return ReactiveProxyBuilder.create(executorService, new RedissonListMultimap(executorService, name), @@ -342,6 +356,20 @@ public class RedissonBatchReactive implements RBatchReactive { new RedissonListMultimapReactive(codec, executorService, name), RListMultimapReactive.class); } + @Override + public RListMultimapReactive getListMultimapCache(String name) { + RListMultimap map = new RedissonListMultimapCache<>(evictionScheduler, executorService, name); + return ReactiveProxyBuilder.create(executorService, map, + new RedissonListMultimapCacheReactive<>(map, executorService), RListMultimapReactive.class); + } + + @Override + public RListMultimapReactive getListMultimapCache(String name, Codec codec) { + RListMultimap map = new RedissonListMultimapCache<>(evictionScheduler, codec, executorService, name); + return ReactiveProxyBuilder.create(executorService, map, + new RedissonListMultimapCacheReactive<>(map, executorService), RListMultimapReactive.class); + } + @Override public RAtomicDoubleReactive getAtomicDouble(String name) { return ReactiveProxyBuilder.create(executorService, new RedissonAtomicDouble(executorService, name), RAtomicDoubleReactive.class);