From db2f746aed8d7d319ab1762ff8d80541416a5013 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Mon, 25 Dec 2023 14:14:53 +0300 Subject: [PATCH] Feature - ability to specify retryInterval, retryAttempts, timeout parameters per Redisson object. #5316 --- .../src/main/java/org/redisson/Redisson.java | 442 ++++++++- .../java/org/redisson/RedissonBuckets.java | 2 +- .../org/redisson/RedissonExecutorService.java | 2 +- .../java/org/redisson/RedissonFuction.java | 2 +- .../java/org/redisson/RedissonObject.java | 2 +- .../org/redisson/RedissonPatternTopic.java | 2 +- .../RedissonPriorityBlockingDeque.java | 5 +- .../java/org/redisson/RedissonReactive.java | 443 ++++++++- .../main/java/org/redisson/RedissonRx.java | 438 ++++++++- .../java/org/redisson/RedissonScript.java | 2 +- .../java/org/redisson/RedissonSearch.java | 6 +- .../main/java/org/redisson/RedissonTopic.java | 2 +- .../org/redisson/api/ExecutorOptions.java | 1 + .../redisson/api/LocalCachedMapOptions.java | 12 + .../org/redisson/api/MapCacheOptions.java | 12 + .../java/org/redisson/api/MapOptions.java | 1 + .../java/org/redisson/api/RedissonClient.java | 875 +++++++++++++++--- .../redisson/api/RedissonReactiveClient.java | 709 +++++++++++--- .../org/redisson/api/RedissonRxClient.java | 702 +++++++++++--- .../java/org/redisson/api/map/WriteMode.java | 38 + .../redisson/api/options/BaseMapOptions.java | 144 +++ .../org/redisson/api/options/BaseOptions.java | 72 ++ .../redisson/api/options/CodecOptions.java | 33 + .../redisson/api/options/CommonOptions.java | 36 + .../redisson/api/options/CommonParams.java | 36 + .../redisson/api/options/ExMapOptions.java | 112 +++ .../redisson/api/options/ExecutorOptions.java | 66 ++ .../redisson/api/options/ExecutorParams.java | 61 ++ .../api/options/InvocationOptions.java | 59 ++ .../api/options/JsonBucketOptions.java | 37 + .../api/options/JsonBucketParams.java | 37 + .../org/redisson/api/options/KeysOptions.java | 35 + .../org/redisson/api/options/KeysParams.java | 29 + .../api/options/LiveObjectOptions.java | 35 + .../api/options/LiveObjectParams.java | 29 + .../api/options/LocalCachedMapOptions.java | 237 +++++ .../api/options/LocalCachedMapParams.java | 231 +++++ .../redisson/api/options/MapCacheOptions.java | 47 + .../redisson/api/options/MapCacheParams.java | 47 + .../org/redisson/api/options/MapOptions.java | 38 + .../org/redisson/api/options/MapParams.java | 37 + .../redisson/api/options/ObjectParams.java | 32 + .../redisson/api/options/OptionalOptions.java | 37 + .../redisson/api/options/OptionalParams.java | 30 + .../api/options/PatternTopicOptions.java | 38 + .../api/options/PatternTopicParams.java | 36 + .../redisson/api/options/PlainOptions.java | 38 + .../org/redisson/api/options/PlainParams.java | 37 + .../command/BaseRedisBatchExecutor.java | 31 +- .../redisson/command/CommandAsyncService.java | 44 +- .../command/RedisCommonBatchExecutor.java | 33 +- .../org/redisson/command/RedisExecutor.java | 16 +- .../redisson/connection/ServiceManager.java | 9 + .../reactive/CommandReactiveService.java | 6 + .../redisson/remote/BaseRemoteService.java | 2 +- .../org/redisson/rx/CommandRxService.java | 6 + .../java/org/redisson/RedissonBucketTest.java | 24 +- 57 files changed, 5108 insertions(+), 467 deletions(-) create mode 100644 redisson/src/main/java/org/redisson/api/map/WriteMode.java create mode 100644 redisson/src/main/java/org/redisson/api/options/BaseMapOptions.java create mode 100644 redisson/src/main/java/org/redisson/api/options/BaseOptions.java create mode 100644 redisson/src/main/java/org/redisson/api/options/CodecOptions.java create mode 100644 redisson/src/main/java/org/redisson/api/options/CommonOptions.java create mode 100644 redisson/src/main/java/org/redisson/api/options/CommonParams.java create mode 100644 redisson/src/main/java/org/redisson/api/options/ExMapOptions.java create mode 100644 redisson/src/main/java/org/redisson/api/options/ExecutorOptions.java create mode 100644 redisson/src/main/java/org/redisson/api/options/ExecutorParams.java create mode 100644 redisson/src/main/java/org/redisson/api/options/InvocationOptions.java create mode 100644 redisson/src/main/java/org/redisson/api/options/JsonBucketOptions.java create mode 100644 redisson/src/main/java/org/redisson/api/options/JsonBucketParams.java create mode 100644 redisson/src/main/java/org/redisson/api/options/KeysOptions.java create mode 100644 redisson/src/main/java/org/redisson/api/options/KeysParams.java create mode 100644 redisson/src/main/java/org/redisson/api/options/LiveObjectOptions.java create mode 100644 redisson/src/main/java/org/redisson/api/options/LiveObjectParams.java create mode 100644 redisson/src/main/java/org/redisson/api/options/LocalCachedMapOptions.java create mode 100644 redisson/src/main/java/org/redisson/api/options/LocalCachedMapParams.java create mode 100644 redisson/src/main/java/org/redisson/api/options/MapCacheOptions.java create mode 100644 redisson/src/main/java/org/redisson/api/options/MapCacheParams.java create mode 100644 redisson/src/main/java/org/redisson/api/options/MapOptions.java create mode 100644 redisson/src/main/java/org/redisson/api/options/MapParams.java create mode 100644 redisson/src/main/java/org/redisson/api/options/ObjectParams.java create mode 100644 redisson/src/main/java/org/redisson/api/options/OptionalOptions.java create mode 100644 redisson/src/main/java/org/redisson/api/options/OptionalParams.java create mode 100644 redisson/src/main/java/org/redisson/api/options/PatternTopicOptions.java create mode 100644 redisson/src/main/java/org/redisson/api/options/PatternTopicParams.java create mode 100644 redisson/src/main/java/org/redisson/api/options/PlainOptions.java create mode 100644 redisson/src/main/java/org/redisson/api/options/PlainParams.java diff --git a/redisson/src/main/java/org/redisson/Redisson.java b/redisson/src/main/java/org/redisson/Redisson.java index ea86d7fdf..b7692eff9 100755 --- a/redisson/src/main/java/org/redisson/Redisson.java +++ b/redisson/src/main/java/org/redisson/Redisson.java @@ -16,6 +16,11 @@ package org.redisson; import org.redisson.api.*; +import org.redisson.api.ExecutorOptions; +import org.redisson.api.LocalCachedMapOptions; +import org.redisson.api.MapCacheOptions; +import org.redisson.api.MapOptions; +import org.redisson.api.options.*; import org.redisson.api.redisnode.*; import org.redisson.client.codec.Codec; import org.redisson.codec.JsonCodec; @@ -33,6 +38,7 @@ import org.redisson.redisnode.RedissonSentinelMasterSlaveNodes; import org.redisson.redisnode.RedissonSingleNode; import org.redisson.transaction.RedissonTransaction; +import java.time.Duration; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.TimeUnit; @@ -166,6 +172,14 @@ public final class Redisson implements RedissonClient { return new RedissonTimeSeries<>(codec, evictionScheduler, commandExecutor, name); } + @Override + public RTimeSeries getTimeSeries(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonTimeSeries<>(params.getCodec(), evictionScheduler, + new CommandAsyncService(commandExecutor, params), + params.getName()); + } + @Override public RStream getStream(String name) { return new RedissonStream(commandExecutor, name); @@ -173,7 +187,13 @@ public final class Redisson implements RedissonClient { @Override public RStream getStream(String name, Codec codec) { - return new RedissonStream(codec, commandExecutor, name); + return new RedissonStream<>(codec, commandExecutor, name); + } + + @Override + public RStream getStream(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonStream<>(params.getCodec(), new CommandAsyncService(commandExecutor, params), params.getName()); } @Override @@ -186,11 +206,23 @@ public final class Redisson implements RedissonClient { return new RedissonSearch(codec, commandExecutor); } + @Override + public RSearch getSearch(OptionalOptions options) { + OptionalParams params = (OptionalParams) options; + return new RedissonSearch(params.getCodec(), new CommandAsyncService(commandExecutor, params)); + } + @Override public RBinaryStream getBinaryStream(String name) { return new RedissonBinaryStream(commandExecutor, name); } + @Override + public RBinaryStream getBinaryStream(CommonOptions options) { + CommonParams params = (CommonParams) options; + return new RedissonBinaryStream(new CommandAsyncService(commandExecutor, params), params.getName()); + } + @Override public RGeo getGeo(String name) { return new RedissonGeo(commandExecutor, name, this); @@ -201,6 +233,13 @@ public final class Redisson implements RedissonClient { return new RedissonGeo(codec, commandExecutor, name, this); } + @Override + public RGeo getGeo(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonGeo<>(params.getCodec(), new CommandAsyncService(commandExecutor, params), + params.getName(), this); + } + @Override public RBucket getBucket(String name) { return new RedissonBucket(commandExecutor, name); @@ -211,9 +250,21 @@ public final class Redisson implements RedissonClient { return new RedissonRateLimiter(commandExecutor, name); } + @Override + public RRateLimiter getRateLimiter(CommonOptions options) { + CommonParams params = (CommonParams) options; + return new RedissonRateLimiter(new CommandAsyncService(commandExecutor, params), params.getName()); + } + @Override public RBucket getBucket(String name, Codec codec) { - return new RedissonBucket(codec, commandExecutor, name); + return new RedissonBucket<>(codec, commandExecutor, name); + } + + @Override + public RBucket getBucket(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonBucket<>(params.getCodec(), new CommandAsyncService(commandExecutor, params), params.getName()); } @Override @@ -226,11 +277,23 @@ public final class Redisson implements RedissonClient { return new RedissonBuckets(codec, commandExecutor); } + @Override + public RBuckets getBuckets(OptionalOptions options) { + OptionalParams params = (OptionalParams) options; + return new RedissonBuckets(params.getCodec(), new CommandAsyncService(commandExecutor, params)); + } + @Override public RJsonBucket getJsonBucket(String name, JsonCodec codec) { return new RedissonJsonBucket<>(codec, commandExecutor, name); } + @Override + public RJsonBucket getJsonBucket(JsonBucketOptions options) { + JsonBucketParams params = (JsonBucketParams) options; + return new RedissonJsonBucket<>(params.getCodec(), commandExecutor, params.getName()); + } + @Override public RHyperLogLog getHyperLogLog(String name) { return new RedissonHyperLogLog(commandExecutor, name); @@ -241,6 +304,12 @@ public final class Redisson implements RedissonClient { return new RedissonHyperLogLog(codec, commandExecutor, name); } + @Override + public RHyperLogLog getHyperLogLog(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonHyperLogLog(params.getCodec(), new CommandAsyncService(commandExecutor, params), params.getName()); + } + @Override public RList getList(String name) { return new RedissonList(commandExecutor, name, this); @@ -251,6 +320,12 @@ public final class Redisson implements RedissonClient { return new RedissonList(codec, commandExecutor, name, this); } + @Override + public RList getList(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonList(params.getCodec(), new CommandAsyncService(commandExecutor, params), params.getName(), this); + } + @Override public RListMultimap getListMultimap(String name) { return new RedissonListMultimap(commandExecutor, name); @@ -261,6 +336,12 @@ public final class Redisson implements RedissonClient { return new RedissonListMultimap(codec, commandExecutor, name); } + @Override + public RListMultimap getListMultimap(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonListMultimap<>(params.getCodec(), new CommandAsyncService(commandExecutor, params), params.getName()); + } + @Override public RLocalCachedMap getLocalCachedMap(String name, LocalCachedMapOptions options) { return new RedissonLocalCachedMap(commandExecutor, name, @@ -273,6 +354,35 @@ public final class Redisson implements RedissonClient { options, evictionScheduler, this, writeBehindService); } + @Override + public RLocalCachedMap getLocalCachedMap(org.redisson.api.options.LocalCachedMapOptions options) { + LocalCachedMapParams params = (LocalCachedMapParams) options; + + LocalCachedMapOptions ops = LocalCachedMapOptions.defaults() + .cacheProvider(LocalCachedMapOptions.CacheProvider.valueOf(params.getCacheProvider().toString())) + .cacheSize(params.getCacheSize()) + .storeMode(LocalCachedMapOptions.StoreMode.valueOf(params.getStoreMode().toString())) + .evictionPolicy(LocalCachedMapOptions.EvictionPolicy.valueOf(params.getEvictionPolicy().toString())) + .maxIdle(params.getMaxIdleInMillis()) + .loader(params.getLoader()) + .loaderAsync(params.getLoaderAsync()) + .reconnectionStrategy(LocalCachedMapOptions.ReconnectionStrategy.valueOf(params.getReconnectionStrategy().toString())) + .storeCacheMiss(params.isStoreCacheMiss()) + .timeToLive(params.getTimeToLiveInMillis()) + .syncStrategy(LocalCachedMapOptions.SyncStrategy.valueOf(params.getSyncStrategy().toString())) + .useKeyEventsPattern(params.isUseKeyEventsPattern()) + .writer(params.getWriter()) + .writerAsync(params.getWriterAsync()) + .writeMode(MapOptions.WriteMode.valueOf(params.getWriteMode().toString())) + .writeBehindDelay(params.getWriteBehindDelay()) + .writeBehindBatchSize(params.getWriteBehindBatchSize()) + .writerRetryAttempts(params.getWriteRetryAttempts()) + .writerRetryInterval(Duration.ofMillis(params.getWriteRetryInterval())); + + return new RedissonLocalCachedMap<>(params.getCodec(), new CommandAsyncService(commandExecutor, params), params.getName(), + ops, evictionScheduler, this, writeBehindService); + } + @Override public RMap getMap(String name) { return new RedissonMap(commandExecutor, name, this, null, null); @@ -283,6 +393,24 @@ public final class Redisson implements RedissonClient { return new RedissonMap(commandExecutor, name, this, options, writeBehindService); } + @Override + public RMap getMap(org.redisson.api.options.MapOptions options) { + MapParams params = (MapParams) options; + MapOptions ops = MapOptions.defaults() + .loader(params.getLoader()) + .loaderAsync(params.getLoaderAsync()) + .writer(params.getWriter()) + .writerAsync(params.getWriterAsync()) + .writeMode(MapOptions.WriteMode.valueOf(params.getWriteMode().toString())) + .writeBehindDelay(params.getWriteBehindDelay()) + .writeBehindBatchSize(params.getWriteBehindBatchSize()) + .writerRetryAttempts(params.getWriteRetryAttempts()) + .writerRetryInterval(Duration.ofMillis(params.getWriteRetryInterval())); + + return new RedissonMap<>(new CommandAsyncService(commandExecutor, params), params.getName(), + this, ops, writeBehindService); + } + @Override public RSetMultimap getSetMultimap(String name) { return new RedissonSetMultimap(commandExecutor, name); @@ -298,6 +426,13 @@ public final class Redisson implements RedissonClient { return new RedissonSetMultimapCache(evictionScheduler, codec, commandExecutor, name); } + @Override + public RSetMultimapCache getSetMultimapCache(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonSetMultimapCache(evictionScheduler, params.getCodec(), + new CommandAsyncService(commandExecutor, params), params.getName()); + } + @Override public RListMultimapCache getListMultimapCache(String name) { return new RedissonListMultimapCache(evictionScheduler, commandExecutor, name); @@ -308,11 +443,24 @@ public final class Redisson implements RedissonClient { return new RedissonListMultimapCache(evictionScheduler, codec, commandExecutor, name); } + @Override + public RListMultimapCache getListMultimapCache(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonListMultimapCache(evictionScheduler, params.getCodec(), + new CommandAsyncService(commandExecutor, params), params.getName()); + } + @Override public RSetMultimap getSetMultimap(String name, Codec codec) { return new RedissonSetMultimap(codec, commandExecutor, name); } + @Override + public RSetMultimap getSetMultimap(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonSetMultimap<>(params.getCodec(), new CommandAsyncService(commandExecutor, params), params.getName()); + } + @Override public RSetCache getSetCache(String name) { return new RedissonSetCache(evictionScheduler, commandExecutor, name, this); @@ -323,6 +471,13 @@ public final class Redisson implements RedissonClient { return new RedissonSetCache(codec, evictionScheduler, commandExecutor, name, this); } + @Override + public RSetCache getSetCache(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonSetCache(params.getCodec(), evictionScheduler, + new CommandAsyncService(commandExecutor, params), params.getName(), this); + } + @Override public RMapCache getMapCache(String name) { return new RedissonMapCache(evictionScheduler, commandExecutor, name, this, null, null); @@ -343,6 +498,27 @@ public final class Redisson implements RedissonClient { return new RedissonMapCache(codec, evictionScheduler, commandExecutor, name, this, options, writeBehindService); } + @Override + public RMapCache getMapCache(org.redisson.api.options.MapCacheOptions options) { + MapCacheParams params = (MapCacheParams) options; + MapCacheOptions ops = MapCacheOptions.defaults() + .loader(params.getLoader()) + .loaderAsync(params.getLoaderAsync()) + .writer(params.getWriter()) + .writerAsync(params.getWriterAsync()) + .writeMode(MapOptions.WriteMode.valueOf(params.getWriteMode().toString())) + .writeBehindDelay(params.getWriteBehindDelay()) + .writeBehindBatchSize(params.getWriteBehindBatchSize()) + .writerRetryAttempts(params.getWriteRetryAttempts()) + .writerRetryInterval(Duration.ofMillis(params.getWriteRetryInterval())); + + if (params.isRemoveEmptyEvictionTask()) { + ops.removeEmptyEvictionTask(); + } + return new RedissonMapCache<>(params.getCodec(), evictionScheduler, + commandExecutor, params.getName(), this, ops, writeBehindService); + } + @Override public RMap getMap(String name, Codec codec) { return new RedissonMap(codec, commandExecutor, name, this, null, null); @@ -358,6 +534,12 @@ public final class Redisson implements RedissonClient { return new RedissonLock(commandExecutor, name); } + @Override + public RLock getLock(CommonOptions options) { + CommonParams params = (CommonParams) options; + return new RedissonLock(new CommandAsyncService(commandExecutor, params), params.getName()); + } + @Override public RLock getSpinLock(String name) { return getSpinLock(name, LockOptions.defaults()); @@ -373,6 +555,12 @@ public final class Redisson implements RedissonClient { return new RedissonFencedLock(commandExecutor, name); } + @Override + public RFencedLock getFencedLock(CommonOptions options) { + CommonParams params = (CommonParams) options; + return new RedissonFencedLock(new CommandAsyncService(commandExecutor, params), params.getName()); + } + @Override public RLock getMultiLock(RLock... locks) { return new RedissonMultiLock(locks); @@ -388,11 +576,23 @@ public final class Redisson implements RedissonClient { return new RedissonFairLock(commandExecutor, name); } + @Override + public RLock getFairLock(CommonOptions options) { + CommonParams params = (CommonParams) options; + return new RedissonFairLock(new CommandAsyncService(commandExecutor, params), params.getName()); + } + @Override public RReadWriteLock getReadWriteLock(String name) { return new RedissonReadWriteLock(commandExecutor, name); } + @Override + public RReadWriteLock getReadWriteLock(CommonOptions options) { + CommonParams params = (CommonParams) options; + return new RedissonReadWriteLock(new CommandAsyncService(commandExecutor, params), params.getName()); + } + @Override public RSet getSet(String name) { return new RedissonSet(commandExecutor, name, this); @@ -403,6 +603,12 @@ public final class Redisson implements RedissonClient { return new RedissonSet(codec, commandExecutor, name, this); } + @Override + public RSet getSet(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonSet(params.getCodec(), new CommandAsyncService(commandExecutor, params), params.getName(), this); + } + @Override public RFunction getFunction() { return new RedissonFuction(commandExecutor); @@ -413,6 +619,12 @@ public final class Redisson implements RedissonClient { return new RedissonFuction(commandExecutor, codec); } + @Override + public RFunction getFunction(OptionalOptions options) { + OptionalParams params = (OptionalParams) options; + return new RedissonFuction(new CommandAsyncService(commandExecutor, params), params.getCodec()); + } + @Override public RScript getScript() { return new RedissonScript(commandExecutor); @@ -423,6 +635,12 @@ public final class Redisson implements RedissonClient { return new RedissonScript(commandExecutor, codec); } + @Override + public RScript getScript(OptionalOptions options) { + OptionalParams params = (OptionalParams) options; + return new RedissonScript(new CommandAsyncService(commandExecutor, params), params.getCodec()); + } + @Override public RScheduledExecutorService getExecutorService(String name) { return getExecutorService(name, connectionManager.getServiceManager().getCfg().getCodec()); @@ -443,6 +661,16 @@ public final class Redisson implements RedissonClient { return new RedissonExecutorService(codec, commandExecutor, this, name, options); } + @Override + public RScheduledExecutorService getExecutorService(org.redisson.api.options.ExecutorOptions options) { + ExecutorParams params = (ExecutorParams) options; + ExecutorOptions ops = ExecutorOptions.defaults() + .idGenerator(params.getIdGenerator()) + .taskRetryInterval(params.getTaskRetryInterval(), TimeUnit.MILLISECONDS); + return new RedissonExecutorService(params.getCodec(), + new CommandAsyncService(commandExecutor, params), this, params.getName(), ops); + } + @Override public RRemoteService getRemoteService() { return getRemoteService("redisson_rs", connectionManager.getServiceManager().getCfg().getCodec()); @@ -467,6 +695,17 @@ public final class Redisson implements RedissonClient { return new RedissonRemoteService(codec, name, commandExecutor, executorId); } + @Override + public RRemoteService getRemoteService(PlainOptions options) { + PlainParams params = (PlainParams) options; + String executorId = connectionManager.getServiceManager().getId(); + if (params.getCodec() != null + && params.getCodec() != connectionManager.getServiceManager().getCfg().getCodec()) { + executorId = executorId + ":" + params.getName(); + } + return new RedissonRemoteService(params.getCodec(), params.getName(), new CommandAsyncService(commandExecutor, params), executorId); + } + @Override public RSortedSet getSortedSet(String name) { return new RedissonSortedSet(commandExecutor, name, this); @@ -477,6 +716,13 @@ public final class Redisson implements RedissonClient { return new RedissonSortedSet(codec, commandExecutor, name, this); } + @Override + public RSortedSet getSortedSet(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonSortedSet(params.getCodec(), + new CommandAsyncService(commandExecutor, params), params.getName(), this); + } + @Override public RScoredSortedSet getScoredSortedSet(String name) { return new RedissonScoredSortedSet(commandExecutor, name, this); @@ -487,11 +733,24 @@ public final class Redisson implements RedissonClient { return new RedissonScoredSortedSet(codec, commandExecutor, name, this); } + @Override + public RScoredSortedSet getScoredSortedSet(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonScoredSortedSet(params.getCodec(), + new CommandAsyncService(commandExecutor, params), params.getName(), this); + } + @Override public RLexSortedSet getLexSortedSet(String name) { return new RedissonLexSortedSet(commandExecutor, name, this); } + @Override + public RLexSortedSet getLexSortedSet(CommonOptions options) { + CommonParams params = (CommonParams) options; + return new RedissonLexSortedSet(new CommandAsyncService(commandExecutor, params), params.getName(), this); + } + @Override public RShardedTopic getShardedTopic(String name) { return new RedissonShardedTopic(commandExecutor, name); @@ -502,6 +761,12 @@ public final class Redisson implements RedissonClient { return new RedissonShardedTopic(codec, commandExecutor, name); } + @Override + public RShardedTopic getShardedTopic(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonShardedTopic(params.getCodec(), new CommandAsyncService(commandExecutor, params), params.getName()); + } + @Override public RTopic getTopic(String name) { return new RedissonTopic(commandExecutor, name); @@ -512,6 +777,12 @@ public final class Redisson implements RedissonClient { return new RedissonTopic(codec, commandExecutor, name); } + @Override + public RTopic getTopic(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonTopic(params.getCodec(), new CommandAsyncService(commandExecutor, params), params.getName()); + } + @Override public RReliableTopic getReliableTopic(String name) { return new RedissonReliableTopic(commandExecutor, name, null); @@ -522,6 +793,13 @@ public final class Redisson implements RedissonClient { return new RedissonReliableTopic(codec, commandExecutor, name, null); } + @Override + public RReliableTopic getReliableTopic(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonReliableTopic(params.getCodec(), + new CommandAsyncService(commandExecutor, params), params.getName(), null); + } + @Override public RPatternTopic getPatternTopic(String pattern) { return new RedissonPatternTopic(commandExecutor, pattern); @@ -532,6 +810,12 @@ public final class Redisson implements RedissonClient { return new RedissonPatternTopic(codec, commandExecutor, pattern); } + @Override + public RPatternTopic getPatternTopic(PatternTopicOptions options) { + PatternTopicParams params = (PatternTopicParams) options; + return new RedissonPatternTopic(params.getCodec(), new CommandAsyncService(commandExecutor, params), params.getPattern()); + } + @Override public RDelayedQueue getDelayedQueue(RQueue destinationQueue) { if (destinationQueue == null) { @@ -550,6 +834,13 @@ public final class Redisson implements RedissonClient { return new RedissonQueue(codec, commandExecutor, name, this); } + @Override + public RQueue getQueue(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonQueue(params.getCodec(), + new CommandAsyncService(commandExecutor, params), params.getName(), this); + } + @Override public RTransferQueue getTransferQueue(String name) { String remoteName = RedissonObject.suffixName(name, "remoteService"); @@ -564,6 +855,15 @@ public final class Redisson implements RedissonClient { return new RedissonTransferQueue(codec, commandExecutor, name, service); } + @Override + public RTransferQueue getTransferQueue(PlainOptions options) { + PlainParams params = (PlainParams) options; + String remoteName = RedissonObject.suffixName(params.getName(), "remoteService"); + RRemoteService service = getRemoteService(remoteName); + return new RedissonTransferQueue(params.getCodec(), + new CommandAsyncService(commandExecutor, params), params.getName(), service); + } + @Override public RRingBuffer getRingBuffer(String name) { return new RedissonRingBuffer(commandExecutor, name, this); @@ -573,7 +873,14 @@ public final class Redisson implements RedissonClient { public RRingBuffer getRingBuffer(String name, Codec codec) { return new RedissonRingBuffer(codec, commandExecutor, name, this); } - + + @Override + public RRingBuffer getRingBuffer(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonRingBuffer(params.getCodec(), + new CommandAsyncService(commandExecutor, params), params.getName(), this); + } + @Override public RBlockingQueue getBlockingQueue(String name) { return new RedissonBlockingQueue(commandExecutor, name, this); @@ -584,6 +891,13 @@ public final class Redisson implements RedissonClient { return new RedissonBlockingQueue(codec, commandExecutor, name, this); } + @Override + public RBlockingQueue getBlockingQueue(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonBlockingQueue(params.getCodec(), + new CommandAsyncService(commandExecutor, params), params.getName(), this); + } + @Override public RBoundedBlockingQueue getBoundedBlockingQueue(String name) { return new RedissonBoundedBlockingQueue(commandExecutor, name, this); @@ -594,6 +908,13 @@ public final class Redisson implements RedissonClient { return new RedissonBoundedBlockingQueue(codec, commandExecutor, name, this); } + @Override + public RBoundedBlockingQueue getBoundedBlockingQueue(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonBoundedBlockingQueue(params.getCodec(), + new CommandAsyncService(commandExecutor, params), params.getName(), this); + } + @Override public RDeque getDeque(String name) { return new RedissonDeque(commandExecutor, name, this); @@ -604,6 +925,13 @@ public final class Redisson implements RedissonClient { return new RedissonDeque(codec, commandExecutor, name, this); } + @Override + public RDeque getDeque(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonDeque(params.getCodec(), + new CommandAsyncService(commandExecutor, params), params.getName(), this); + } + @Override public RBlockingDeque getBlockingDeque(String name) { return new RedissonBlockingDeque(commandExecutor, name, this); @@ -612,48 +940,103 @@ public final class Redisson implements RedissonClient { @Override public RBlockingDeque getBlockingDeque(String name, Codec codec) { return new RedissonBlockingDeque(codec, commandExecutor, name, this); - }; + } + + @Override + public RBlockingDeque getBlockingDeque(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonBlockingDeque(params.getCodec(), + new CommandAsyncService(commandExecutor, params), params.getName(), this); + } @Override public RAtomicLong getAtomicLong(String name) { return new RedissonAtomicLong(commandExecutor, name); } + @Override + public RAtomicLong getAtomicLong(CommonOptions options) { + CommonParams params = (CommonParams) options; + return new RedissonAtomicLong(new CommandAsyncService(commandExecutor, params), params.getName()); + } + @Override public RLongAdder getLongAdder(String name) { return new RedissonLongAdder(commandExecutor, name, this); } + @Override + public RLongAdder getLongAdder(CommonOptions options) { + CommonParams params = (CommonParams) options; + return new RedissonLongAdder(new CommandAsyncService(commandExecutor, params), params.getName(), this); + } + @Override public RDoubleAdder getDoubleAdder(String name) { return new RedissonDoubleAdder(commandExecutor, name, this); } + @Override + public RDoubleAdder getDoubleAdder(CommonOptions options) { + CommonParams params = (CommonParams) options; + return new RedissonDoubleAdder(new CommandAsyncService(commandExecutor, params), params.getName(), this); + } + @Override public RAtomicDouble getAtomicDouble(String name) { return new RedissonAtomicDouble(commandExecutor, name); } + @Override + public RAtomicDouble getAtomicDouble(CommonOptions options) { + CommonParams params = (CommonParams) options; + return new RedissonAtomicDouble(new CommandAsyncService(commandExecutor, params), params.getName()); + } + @Override public RCountDownLatch getCountDownLatch(String name) { return new RedissonCountDownLatch(commandExecutor, name); } + @Override + public RCountDownLatch getCountDownLatch(CommonOptions options) { + CommonParams params = (CommonParams) options; + return new RedissonCountDownLatch(new CommandAsyncService(commandExecutor, params), params.getName()); + } + @Override public RBitSet getBitSet(String name) { return new RedissonBitSet(commandExecutor, name); } + @Override + public RBitSet getBitSet(CommonOptions options) { + CommonParams params = (CommonParams) options; + return new RedissonBitSet(new CommandAsyncService(commandExecutor, params), params.getName()); + } + @Override public RSemaphore getSemaphore(String name) { return new RedissonSemaphore(commandExecutor, name); } + @Override + public RSemaphore getSemaphore(CommonOptions options) { + CommonParams params = (CommonParams) options; + return new RedissonSemaphore(new CommandAsyncService(commandExecutor, params), params.getName()); + } + @Override public RPermitExpirableSemaphore getPermitExpirableSemaphore(String name) { return new RedissonPermitExpirableSemaphore(commandExecutor, name); } + @Override + public RPermitExpirableSemaphore getPermitExpirableSemaphore(CommonOptions options) { + CommonParams params = (CommonParams) options; + return new RedissonPermitExpirableSemaphore(new CommandAsyncService(commandExecutor, params), params.getName()); + } + @Override public RBloomFilter getBloomFilter(String name) { return new RedissonBloomFilter(commandExecutor, name); @@ -664,16 +1047,34 @@ public final class Redisson implements RedissonClient { return new RedissonBloomFilter(codec, commandExecutor, name); } + @Override + public RBloomFilter getBloomFilter(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonBloomFilter(params.getCodec(), new CommandAsyncService(commandExecutor, params), params.getName()); + } + @Override public RIdGenerator getIdGenerator(String name) { return new RedissonIdGenerator(commandExecutor, name); } + @Override + public RIdGenerator getIdGenerator(CommonOptions options) { + CommonParams params = (CommonParams) options; + return new RedissonIdGenerator(new CommandAsyncService(commandExecutor, params), params.getName()); + } + @Override public RKeys getKeys() { return new RedissonKeys(commandExecutor); } + @Override + public RKeys getKeys(KeysOptions options) { + KeysParams params = (KeysParams) options; + return new RedissonKeys(new CommandAsyncService(commandExecutor, params)); + } + @Override public RTransaction createTransaction(TransactionOptions options) { return new RedissonTransaction(commandExecutor, options); @@ -694,6 +1095,12 @@ public final class Redisson implements RedissonClient { return new RedissonLiveObjectService(liveObjectClassCache, commandExecutor); } + @Override + public RLiveObjectService getLiveObjectService(LiveObjectOptions options) { + LiveObjectParams params = (LiveObjectParams) options; + return new RedissonLiveObjectService(liveObjectClassCache, new CommandAsyncService(commandExecutor, params)); + } + @Override public void shutdown() { writeBehindService.stop(); @@ -774,6 +1181,13 @@ public final class Redisson implements RedissonClient { return new RedissonPriorityQueue(codec, commandExecutor, name, this); } + @Override + public RPriorityQueue getPriorityQueue(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonPriorityQueue(params.getCodec(), + new CommandAsyncService(commandExecutor, params), params.getName(), this); + } + @Override public RPriorityBlockingQueue getPriorityBlockingQueue(String name) { return new RedissonPriorityBlockingQueue(commandExecutor, name, this); @@ -784,6 +1198,13 @@ public final class Redisson implements RedissonClient { return new RedissonPriorityBlockingQueue(codec, commandExecutor, name, this); } + @Override + public RPriorityBlockingQueue getPriorityBlockingQueue(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonPriorityBlockingQueue(params.getCodec(), + new CommandAsyncService(commandExecutor, params), params.getName(), this); + } + @Override public RPriorityBlockingDeque getPriorityBlockingDeque(String name) { return new RedissonPriorityBlockingDeque(commandExecutor, name, this); @@ -794,6 +1215,12 @@ public final class Redisson implements RedissonClient { return new RedissonPriorityBlockingDeque(codec, commandExecutor, name, this); } + @Override + public RPriorityBlockingDeque getPriorityBlockingDeque(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonPriorityBlockingDeque(params.getCodec(), + new CommandAsyncService(commandExecutor, params), params.getName(), this); + } @Override public RPriorityDeque getPriorityDeque(String name) { @@ -805,6 +1232,13 @@ public final class Redisson implements RedissonClient { return new RedissonPriorityDeque(codec, commandExecutor, name, this); } + @Override + public RPriorityDeque getPriorityDeque(PlainOptions options) { + PlainParams params = (PlainParams) options; + return new RedissonPriorityDeque(params.getCodec(), + new CommandAsyncService(commandExecutor, params), params.getName(), this); + } + @Override public String getId() { return connectionManager.getServiceManager().getId(); diff --git a/redisson/src/main/java/org/redisson/RedissonBuckets.java b/redisson/src/main/java/org/redisson/RedissonBuckets.java index fb44cb681..8d7e223dd 100644 --- a/redisson/src/main/java/org/redisson/RedissonBuckets.java +++ b/redisson/src/main/java/org/redisson/RedissonBuckets.java @@ -49,7 +49,7 @@ public class RedissonBuckets implements RBuckets { public RedissonBuckets(Codec codec, CommandAsyncExecutor commandExecutor) { super(); - this.codec = codec; + this.codec = commandExecutor.getServiceManager().getCodec(codec); this.commandExecutor = commandExecutor; } diff --git a/redisson/src/main/java/org/redisson/RedissonExecutorService.java b/redisson/src/main/java/org/redisson/RedissonExecutorService.java index d78d20956..835c1d68a 100644 --- a/redisson/src/main/java/org/redisson/RedissonExecutorService.java +++ b/redisson/src/main/java/org/redisson/RedissonExecutorService.java @@ -103,7 +103,7 @@ public class RedissonExecutorService implements RScheduledExecutorService { public RedissonExecutorService(Codec codec, CommandAsyncExecutor commandExecutor, Redisson redisson, String name, ExecutorOptions options) { super(); - this.codec = codec; + this.codec = commandExecutor.getServiceManager().getCodec(codec); this.commandExecutor = commandExecutor; this.name = commandExecutor.getServiceManager().getConfig().getNameMapper().map(name); this.redisson = redisson; diff --git a/redisson/src/main/java/org/redisson/RedissonFuction.java b/redisson/src/main/java/org/redisson/RedissonFuction.java index e2e4855f4..e848496ce 100644 --- a/redisson/src/main/java/org/redisson/RedissonFuction.java +++ b/redisson/src/main/java/org/redisson/RedissonFuction.java @@ -44,7 +44,7 @@ public class RedissonFuction implements RFunction { public RedissonFuction(CommandAsyncExecutor commandExecutor, Codec codec) { this.commandExecutor = commandExecutor; - this.codec = codec; + this.codec = commandExecutor.getServiceManager().getCodec(codec); } @Override diff --git a/redisson/src/main/java/org/redisson/RedissonObject.java b/redisson/src/main/java/org/redisson/RedissonObject.java index 9f7e5c5e7..350fea257 100644 --- a/redisson/src/main/java/org/redisson/RedissonObject.java +++ b/redisson/src/main/java/org/redisson/RedissonObject.java @@ -50,7 +50,7 @@ public abstract class RedissonObject implements RObject { protected final Codec codec; public RedissonObject(Codec codec, CommandAsyncExecutor commandExecutor, String name) { - this.codec = codec; + this.codec = commandExecutor.getServiceManager().getCodec(codec); this.commandExecutor = commandExecutor; if (name == null) { throw new NullPointerException("name can't be null"); diff --git a/redisson/src/main/java/org/redisson/RedissonPatternTopic.java b/redisson/src/main/java/org/redisson/RedissonPatternTopic.java index 1e5886e8c..aa71bddbd 100644 --- a/redisson/src/main/java/org/redisson/RedissonPatternTopic.java +++ b/redisson/src/main/java/org/redisson/RedissonPatternTopic.java @@ -55,7 +55,7 @@ public class RedissonPatternTopic implements RPatternTopic { this.commandExecutor = commandExecutor; this.name = name; this.channelName = new ChannelName(name); - this.codec = codec; + this.codec = commandExecutor.getServiceManager().getCodec(codec); this.subscribeService = commandExecutor.getConnectionManager().getSubscribeService(); } diff --git a/redisson/src/main/java/org/redisson/RedissonPriorityBlockingDeque.java b/redisson/src/main/java/org/redisson/RedissonPriorityBlockingDeque.java index aa4613d0c..554b81220 100644 --- a/redisson/src/main/java/org/redisson/RedissonPriorityBlockingDeque.java +++ b/redisson/src/main/java/org/redisson/RedissonPriorityBlockingDeque.java @@ -47,13 +47,12 @@ public class RedissonPriorityBlockingDeque extends RedissonPriorityDeque i protected RedissonPriorityBlockingDeque(CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson) { super(commandExecutor, name, redisson); - blockingQueue = (RedissonPriorityBlockingQueue) redisson.getPriorityBlockingQueue(name); + blockingQueue = new RedissonPriorityBlockingQueue(commandExecutor, name, redisson); } protected RedissonPriorityBlockingDeque(Codec codec, CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson) { super(codec, commandExecutor, name, redisson); - - blockingQueue = (RedissonPriorityBlockingQueue) redisson.getPriorityBlockingQueue(name, codec); + blockingQueue = new RedissonPriorityBlockingQueue(codec, commandExecutor, name, redisson); } @Override diff --git a/redisson/src/main/java/org/redisson/RedissonReactive.java b/redisson/src/main/java/org/redisson/RedissonReactive.java index 0dc445b74..a6ab4f412 100644 --- a/redisson/src/main/java/org/redisson/RedissonReactive.java +++ b/redisson/src/main/java/org/redisson/RedissonReactive.java @@ -15,9 +15,14 @@ */ package org.redisson; +import org.redisson.api.LocalCachedMapOptions; +import org.redisson.api.MapCacheOptions; +import org.redisson.api.MapOptions; import org.redisson.api.*; +import org.redisson.api.options.*; import org.redisson.client.codec.Codec; import org.redisson.codec.JsonCodec; +import org.redisson.command.CommandAsyncService; import org.redisson.config.Config; import org.redisson.config.ConfigSupport; import org.redisson.connection.ConnectionManager; @@ -25,6 +30,7 @@ import org.redisson.eviction.EvictionScheduler; import org.redisson.liveobject.core.RedissonObjectBuilder; import org.redisson.reactive.*; +import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -68,14 +74,6 @@ public class RedissonReactive implements RedissonReactiveClient { this.writeBehindService = writeBehindService; } - public EvictionScheduler getEvictionScheduler() { - return evictionScheduler; - } - - public ConnectionManager getConnectionManager() { - return connectionManager; - } - public CommandReactiveExecutor getCommandExecutor() { return commandExecutor; } @@ -90,9 +88,17 @@ public class RedissonReactive implements RedissonReactiveClient { return ReactiveProxyBuilder.create(commandExecutor, new RedissonStream(codec, commandExecutor, name), RStreamReactive.class); } + @Override + public RStreamReactive getStream(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, + new RedissonStream(params.getCodec(), ca, params.getName()), RStreamReactive.class); + } + @Override public RSearchReactive getSearch() { - return getSearch(null); + return getSearch((Codec) null); } @Override @@ -100,6 +106,13 @@ public class RedissonReactive implements RedissonReactiveClient { return ReactiveProxyBuilder.create(commandExecutor, new RedissonSearch(codec, commandExecutor), RSearchReactive.class); } + @Override + public RSearchReactive getSearch(OptionalOptions options) { + OptionalParams params = (OptionalParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, new RedissonSearch(params.getCodec(), ca), RSearchReactive.class); + } + @Override public RGeoReactive getGeo(String name) { return ReactiveProxyBuilder.create(commandExecutor, new RedissonGeo(commandExecutor, name, null), @@ -111,17 +124,40 @@ public class RedissonReactive implements RedissonReactiveClient { return ReactiveProxyBuilder.create(commandExecutor, new RedissonGeo(codec, commandExecutor, name, null), new RedissonScoredSortedSetReactive(codec, commandExecutor, name), RGeoReactive.class); } - + + @Override + public RGeoReactive getGeo(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandReactiveService ca = new CommandReactiveService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, + new RedissonGeo(params.getCodec(), ca, params.getName(), null), + new RedissonScoredSortedSetReactive(params.getCodec(), ca, params.getName()), RGeoReactive.class); + } + @Override public RLockReactive getFairLock(String name) { return ReactiveProxyBuilder.create(commandExecutor, new RedissonFairLock(commandExecutor, name), RLockReactive.class); } - + + @Override + public RLockReactive getFairLock(CommonOptions options) { + CommonParams params = (CommonParams) options; + CommandReactiveService ca = new CommandReactiveService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, new RedissonFairLock(ca, params.getName()), RLockReactive.class); + } + @Override public RRateLimiterReactive getRateLimiter(String name) { return ReactiveProxyBuilder.create(commandExecutor, new RedissonRateLimiter(commandExecutor, name), RRateLimiterReactive.class); } - + + @Override + public RRateLimiterReactive getRateLimiter(CommonOptions options) { + CommonParams params = (CommonParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, new RedissonRateLimiter(ca, params.getName()), RRateLimiterReactive.class); + } + @Override public RBinaryStreamReactive getBinaryStream(String name) { RedissonBinaryStream stream = new RedissonBinaryStream(commandExecutor, name); @@ -129,26 +165,64 @@ public class RedissonReactive implements RedissonReactiveClient { new RedissonBinaryStreamReactive(commandExecutor, stream), RBinaryStreamReactive.class); } + @Override + public RBinaryStreamReactive getBinaryStream(CommonOptions options) { + CommonParams params = (CommonParams) options; + CommandReactiveService ca = new CommandReactiveService(commandExecutor, params); + RedissonBinaryStream stream = new RedissonBinaryStream(ca, params.getName()); + return ReactiveProxyBuilder.create(commandExecutor, stream, + new RedissonBinaryStreamReactive(ca, stream), RBinaryStreamReactive.class); + } + @Override public RSemaphoreReactive getSemaphore(String name) { return ReactiveProxyBuilder.create(commandExecutor, new RedissonSemaphore(commandExecutor, name), RSemaphoreReactive.class); } + @Override + public RSemaphoreReactive getSemaphore(CommonOptions options) { + CommonParams params = (CommonParams) options; + CommandReactiveService ca = new CommandReactiveService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, new RedissonSemaphore(ca, params.getName()), RSemaphoreReactive.class); + } + @Override public RPermitExpirableSemaphoreReactive getPermitExpirableSemaphore(String name) { return ReactiveProxyBuilder.create(commandExecutor, new RedissonPermitExpirableSemaphore(commandExecutor, name), RPermitExpirableSemaphoreReactive.class); } + @Override + public RPermitExpirableSemaphoreReactive getPermitExpirableSemaphore(CommonOptions options) { + CommonParams params = (CommonParams) options; + CommandReactiveService ca = new CommandReactiveService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, + new RedissonPermitExpirableSemaphore(ca, params.getName()), RPermitExpirableSemaphoreReactive.class); + } + @Override public RReadWriteLockReactive getReadWriteLock(String name) { return new RedissonReadWriteLockReactive(commandExecutor, name); } + @Override + public RReadWriteLockReactive getReadWriteLock(CommonOptions options) { + CommonParams params = (CommonParams) options; + CommandReactiveService ca = new CommandReactiveService(commandExecutor, params); + return new RedissonReadWriteLockReactive(ca, params.getName()); + } + @Override public RLockReactive getLock(String name) { return ReactiveProxyBuilder.create(commandExecutor, new RedissonLock(commandExecutor, name), RLockReactive.class); } + @Override + public RLockReactive getLock(CommonOptions options) { + CommonParams params = (CommonParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, new RedissonLock(ca, params.getName()), RLockReactive.class); + } + @Override public RLockReactive getSpinLock(String name) { return getSpinLock(name, LockOptions.defaults()); @@ -166,6 +240,14 @@ public class RedissonReactive implements RedissonReactiveClient { return ReactiveProxyBuilder.create(commandExecutor, lock, RFencedLockReactive.class); } + @Override + public RFencedLockReactive getFencedLock(CommonOptions options) { + CommonParams params = (CommonParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + RedissonFencedLock lock = new RedissonFencedLock(ca, params.getName()); + return ReactiveProxyBuilder.create(commandExecutor, lock, RFencedLockReactive.class); + } + @Override public RLockReactive getMultiLock(RLockReactive... locks) { RLock[] ls = Arrays.stream(locks) @@ -189,20 +271,37 @@ public class RedissonReactive implements RedissonReactiveClient { return ReactiveProxyBuilder.create(commandExecutor, new RedissonCountDownLatch(commandExecutor, name), RCountDownLatchReactive.class); } + @Override + public RCountDownLatchReactive getCountDownLatch(CommonOptions options) { + CommonParams params = (CommonParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, new RedissonCountDownLatch(ca, params.getName()), RCountDownLatchReactive.class); + } + @Override public RMapCacheReactive getMapCache(String name, Codec codec) { - RMapCache map = new RedissonMapCache(codec, evictionScheduler, commandExecutor, name, null, null, null); + RMapCache map = new RedissonMapCache(codec, evictionScheduler, commandExecutor, name, null, null, writeBehindService); return ReactiveProxyBuilder.create(commandExecutor, map, new RedissonMapCacheReactive(map, commandExecutor), RMapCacheReactive.class); } @Override public RMapCacheReactive getMapCache(String name) { - RMapCache map = new RedissonMapCache(evictionScheduler, commandExecutor, name, null, null, null); + RMapCache map = new RedissonMapCache(evictionScheduler, commandExecutor, name, null, null, writeBehindService); return ReactiveProxyBuilder.create(commandExecutor, map, new RedissonMapCacheReactive(map, commandExecutor), RMapCacheReactive.class); } + @Override + public RMapCacheReactive getMapCache(org.redisson.api.options.MapCacheOptions options) { + MapCacheParams params = (MapCacheParams) options; + CommandReactiveService ca = new CommandReactiveService(commandExecutor, params); + RMapCache map = new RedissonMapCache<>(params.getCodec(), evictionScheduler, ca, + params.getName(), null, null, writeBehindService); + return ReactiveProxyBuilder.create(commandExecutor, map, + new RedissonMapCacheReactive(map, ca), RMapCacheReactive.class); + } + @Override public RBucketReactive getBucket(String name) { return ReactiveProxyBuilder.create(commandExecutor, new RedissonBucket(commandExecutor, name), RBucketReactive.class); @@ -213,6 +312,14 @@ public class RedissonReactive implements RedissonReactiveClient { return ReactiveProxyBuilder.create(commandExecutor, new RedissonBucket(codec, commandExecutor, name), RBucketReactive.class); } + @Override + public RBucketReactive getBucket(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, + new RedissonBucket(params.getCodec(), ca, params.getName()), RBucketReactive.class); + } + @Override public RBucketsReactive getBuckets() { return ReactiveProxyBuilder.create(commandExecutor, new RedissonBuckets(commandExecutor), RBucketsReactive.class); @@ -223,6 +330,13 @@ public class RedissonReactive implements RedissonReactiveClient { return ReactiveProxyBuilder.create(commandExecutor, new RedissonBuckets(codec, commandExecutor), RBucketsReactive.class); } + @Override + public RBucketsReactive getBuckets(OptionalOptions options) { + OptionalParams params = (OptionalParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, new RedissonBuckets(params.getCodec(), ca), RBucketsReactive.class); + } + @Override public List> findBuckets(String pattern) { RKeys redissonKeys = new RedissonKeys(commandExecutor); @@ -242,6 +356,14 @@ public class RedissonReactive implements RedissonReactiveClient { return ReactiveProxyBuilder.create(commandExecutor, new RedissonJsonBucket(codec, commandExecutor, name), RJsonBucketReactive.class); } + @Override + public RJsonBucketReactive getJsonBucket(JsonBucketOptions options) { + JsonBucketParams params = (JsonBucketParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, + new RedissonJsonBucket(params.getCodec(), ca, params.getName()), RJsonBucketReactive.class); + } + @Override public RHyperLogLogReactive getHyperLogLog(String name) { return ReactiveProxyBuilder.create(commandExecutor, new RedissonHyperLogLog(commandExecutor, name), RHyperLogLogReactive.class); @@ -252,11 +374,26 @@ public class RedissonReactive implements RedissonReactiveClient { return ReactiveProxyBuilder.create(commandExecutor, new RedissonHyperLogLog(codec, commandExecutor, name), RHyperLogLogReactive.class); } + @Override + public RHyperLogLogReactive getHyperLogLog(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, + new RedissonHyperLogLog(params.getCodec(), ca, params.getName()), RHyperLogLogReactive.class); + } + @Override public RIdGeneratorReactive getIdGenerator(String name) { return ReactiveProxyBuilder.create(commandExecutor, new RedissonIdGenerator(commandExecutor, name), RIdGeneratorReactive.class); } + @Override + public RIdGeneratorReactive getIdGenerator(CommonOptions options) { + CommonParams params = (CommonParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, new RedissonIdGenerator(ca, params.getName()), RIdGeneratorReactive.class); + } + @Override public RListReactive getList(String name) { return ReactiveProxyBuilder.create(commandExecutor, new RedissonList(commandExecutor, name, null), @@ -269,6 +406,14 @@ public class RedissonReactive implements RedissonReactiveClient { new RedissonListReactive(codec, commandExecutor, name), RListReactive.class); } + @Override + public RListReactive getList(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandReactiveService ca = new CommandReactiveService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, new RedissonList(params.getCodec(), ca, params.getName(), null), + new RedissonListReactive(params.getCodec(), ca, params.getName()), RListReactive.class); + } + @Override public RListMultimapReactive getListMultimap(String name) { return ReactiveProxyBuilder.create(commandExecutor, new RedissonListMultimap(commandExecutor, name), @@ -281,6 +426,14 @@ public class RedissonReactive implements RedissonReactiveClient { new RedissonListMultimapReactive(codec, commandExecutor, name), RListMultimapReactive.class); } + @Override + public RListMultimapReactive getListMultimap(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandReactiveService ca = new CommandReactiveService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, new RedissonListMultimap(params.getCodec(), ca, params.getName()), + new RedissonListMultimapReactive(params.getCodec(), ca, params.getName()), RListMultimapReactive.class); + } + @Override public RSetMultimapReactive getSetMultimap(String name) { return ReactiveProxyBuilder.create(commandExecutor, new RedissonSetMultimap(commandExecutor, name), @@ -293,6 +446,14 @@ public class RedissonReactive implements RedissonReactiveClient { new RedissonSetMultimapReactive(codec, commandExecutor, name, this), RSetMultimapReactive.class); } + @Override + public RSetMultimapReactive getSetMultimap(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandReactiveService ca = new CommandReactiveService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, new RedissonSetMultimap(params.getCodec(), ca, params.getName()), + new RedissonSetMultimapReactive(params.getCodec(), ca, params.getName(), this), RSetMultimapReactive.class); + } + @Override public RListMultimapCacheReactive getListMultimapCache(String name) { RedissonListMultimapCache listMultimap = new RedissonListMultimapCache<>(evictionScheduler, commandExecutor, name); @@ -307,6 +468,15 @@ public class RedissonReactive implements RedissonReactiveClient { new RedissonListMultimapCacheReactive<>(listMultimap, commandExecutor), RListMultimapCacheReactive.class); } + @Override + public RListMultimapCacheReactive getListMultimapCache(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandReactiveService ca = new CommandReactiveService(commandExecutor, params); + RedissonListMultimapCache listMultimap = new RedissonListMultimapCache<>(evictionScheduler, params.getCodec(), ca, params.getName()); + return ReactiveProxyBuilder.create(commandExecutor, listMultimap, + new RedissonListMultimapCacheReactive<>(listMultimap, ca), RListMultimapCacheReactive.class); + } + @Override public RSetMultimapCacheReactive getSetMultimapCache(String name) { RedissonSetMultimapCache setMultimap = new RedissonSetMultimapCache<>(evictionScheduler, commandExecutor, name); @@ -321,20 +491,38 @@ public class RedissonReactive implements RedissonReactiveClient { new RedissonSetMultimapCacheReactive(setMultimap, commandExecutor, this), RSetMultimapCacheReactive.class); } + @Override + public RSetMultimapCacheReactive getSetMultimapCache(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandReactiveService ca = new CommandReactiveService(commandExecutor, params); + RedissonSetMultimapCache setMultimap = new RedissonSetMultimapCache<>(evictionScheduler, params.getCodec(), ca, params.getName()); + return ReactiveProxyBuilder.create(commandExecutor, setMultimap, + new RedissonSetMultimapCacheReactive(setMultimap, ca, this), RSetMultimapCacheReactive.class); + } + @Override public RMapReactive getMap(String name) { - RedissonMap map = new RedissonMap(commandExecutor, name, null, null, null); + RedissonMap map = new RedissonMap(commandExecutor, name, null, null, writeBehindService); return ReactiveProxyBuilder.create(commandExecutor, map, new RedissonMapReactive(map, commandExecutor), RMapReactive.class); } @Override public RMapReactive getMap(String name, Codec codec) { - RedissonMap map = new RedissonMap(codec, commandExecutor, name, null, null, null); + RedissonMap map = new RedissonMap(codec, commandExecutor, name, null, null, writeBehindService); return ReactiveProxyBuilder.create(commandExecutor, map, new RedissonMapReactive(map, commandExecutor), RMapReactive.class); } + @Override + public RMapReactive getMap(org.redisson.api.options.MapOptions options) { + MapParams params = (MapParams) options; + CommandReactiveService ca = new CommandReactiveService(commandExecutor, params); + RedissonMap map = new RedissonMap<>(params.getCodec(), ca, params.getName(), null, null, writeBehindService); + return ReactiveProxyBuilder.create(commandExecutor, map, + new RedissonMapReactive(map, ca), RMapReactive.class); + } + @Override public RSetReactive getSet(String name) { RedissonSet set = new RedissonSet(commandExecutor, name, null); @@ -349,6 +537,15 @@ public class RedissonReactive implements RedissonReactiveClient { new RedissonSetReactive(set, this), RSetReactive.class); } + @Override + public RSetReactive getSet(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + RedissonSet set = new RedissonSet(params.getCodec(), ca, params.getName(), null); + return ReactiveProxyBuilder.create(commandExecutor, set, + new RedissonSetReactive(set, this), RSetReactive.class); + } + @Override public RScoredSortedSetReactive getScoredSortedSet(String name) { return ReactiveProxyBuilder.create(commandExecutor, new RedissonScoredSortedSet(commandExecutor, name, null), @@ -361,6 +558,14 @@ public class RedissonReactive implements RedissonReactiveClient { new RedissonScoredSortedSetReactive(codec, commandExecutor, name), RScoredSortedSetReactive.class); } + @Override + public RScoredSortedSetReactive getScoredSortedSet(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandReactiveService ca = new CommandReactiveService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, new RedissonScoredSortedSet(params.getCodec(), ca, params.getName(), null), + new RedissonScoredSortedSetReactive(params.getCodec(), ca, params.getName()), RScoredSortedSetReactive.class); + } + @Override public RLexSortedSetReactive getLexSortedSet(String name) { RedissonLexSortedSet set = new RedissonLexSortedSet(commandExecutor, name, null); @@ -369,6 +574,16 @@ public class RedissonReactive implements RedissonReactiveClient { RLexSortedSetReactive.class); } + @Override + public RLexSortedSetReactive getLexSortedSet(CommonOptions options) { + CommonParams params = (CommonParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + RedissonLexSortedSet set = new RedissonLexSortedSet(ca, params.getName(), null); + return ReactiveProxyBuilder.create(commandExecutor, set, + new RedissonLexSortedSetReactive(set), + RLexSortedSetReactive.class); + } + @Override public RShardedTopicReactive getShardedTopic(String name) { RedissonShardedTopic topic = new RedissonShardedTopic(commandExecutor, name); @@ -383,6 +598,15 @@ public class RedissonReactive implements RedissonReactiveClient { new RedissonTopicReactive(topic), RShardedTopicReactive.class); } + @Override + public RShardedTopicReactive getShardedTopic(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + RedissonShardedTopic topic = new RedissonShardedTopic(params.getCodec(), ca, params.getName()); + return ReactiveProxyBuilder.create(commandExecutor, topic, + new RedissonTopicReactive(topic), RShardedTopicReactive.class); + } + @Override public RTopicReactive getTopic(String name) { RedissonTopic topic = new RedissonTopic(commandExecutor, name); @@ -397,6 +621,15 @@ public class RedissonReactive implements RedissonReactiveClient { new RedissonTopicReactive(topic), RTopicReactive.class); } + @Override + public RTopicReactive getTopic(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + RedissonTopic topic = new RedissonTopic(params.getCodec(), ca, params.getName()); + return ReactiveProxyBuilder.create(commandExecutor, topic, + new RedissonTopicReactive(topic), RTopicReactive.class); + } + @Override public RReliableTopicReactive getReliableTopic(String name) { RedissonReliableTopic topic = new RedissonReliableTopic(commandExecutor, name, null); @@ -411,6 +644,15 @@ public class RedissonReactive implements RedissonReactiveClient { new RedissonReliableTopicReactive(topic), RReliableTopicReactive.class); } + @Override + public RReliableTopicReactive getReliableTopic(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + RedissonReliableTopic topic = new RedissonReliableTopic(params.getCodec(), ca, params.getName(), null); + return ReactiveProxyBuilder.create(commandExecutor, topic, + new RedissonReliableTopicReactive(topic), RReliableTopicReactive.class); + } + @Override public RPatternTopicReactive getPatternTopic(String pattern) { return ReactiveProxyBuilder.create(commandExecutor, new RedissonPatternTopic(commandExecutor, pattern), RPatternTopicReactive.class); @@ -421,6 +663,14 @@ public class RedissonReactive implements RedissonReactiveClient { return ReactiveProxyBuilder.create(commandExecutor, new RedissonPatternTopic(codec, commandExecutor, pattern), RPatternTopicReactive.class); } + @Override + public RPatternTopicReactive getPatternTopic(PatternTopicOptions options) { + PatternTopicParams params = (PatternTopicParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, + new RedissonPatternTopic(params.getCodec(), ca, params.getPattern()), RPatternTopicReactive.class); + } + @Override public RQueueReactive getQueue(String name) { return ReactiveProxyBuilder.create(commandExecutor, new RedissonQueue(commandExecutor, name, null), @@ -432,7 +682,15 @@ public class RedissonReactive implements RedissonReactiveClient { return ReactiveProxyBuilder.create(commandExecutor, new RedissonQueue(codec, commandExecutor, name, null), new RedissonListReactive(codec, commandExecutor, name), RQueueReactive.class); } - + + @Override + public RQueueReactive getQueue(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandReactiveService ca = new CommandReactiveService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, new RedissonQueue(params.getCodec(), ca, params.getName(), null), + new RedissonListReactive(params.getCodec(), ca, params.getName()), RQueueReactive.class); + } + @Override public RRingBufferReactive getRingBuffer(String name) { return ReactiveProxyBuilder.create(commandExecutor, new RedissonRingBuffer(commandExecutor, name, null), RRingBufferReactive.class); @@ -443,6 +701,14 @@ public class RedissonReactive implements RedissonReactiveClient { return ReactiveProxyBuilder.create(commandExecutor, new RedissonRingBuffer(codec, commandExecutor, name, null), RRingBufferReactive.class); } + @Override + public RRingBufferReactive getRingBuffer(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, + new RedissonRingBuffer(params.getCodec(), ca, params.getName(), null), RRingBufferReactive.class); + } + @Override public RBlockingQueueReactive getBlockingQueue(String name) { RedissonBlockingQueue queue = new RedissonBlockingQueue(commandExecutor, name, null); @@ -457,6 +723,15 @@ public class RedissonReactive implements RedissonReactiveClient { new RedissonBlockingQueueReactive(queue), RBlockingQueueReactive.class); } + @Override + public RBlockingQueueReactive getBlockingQueue(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + RedissonBlockingQueue queue = new RedissonBlockingQueue(params.getCodec(), ca, params.getName(), null); + return ReactiveProxyBuilder.create(commandExecutor, queue, + new RedissonBlockingQueueReactive(queue), RBlockingQueueReactive.class); + } + @Override public RDequeReactive getDeque(String name) { return ReactiveProxyBuilder.create(commandExecutor, new RedissonDeque(commandExecutor, name, null), @@ -469,6 +744,14 @@ public class RedissonReactive implements RedissonReactiveClient { new RedissonListReactive(codec, commandExecutor, name), RDequeReactive.class); } + @Override + public RDequeReactive getDeque(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandReactiveService ca = new CommandReactiveService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, new RedissonDeque(params.getCodec(), ca, params.getName(), null), + new RedissonListReactive(params.getCodec(), ca, params.getName()), RDequeReactive.class); + } + @Override public RTimeSeriesReactive getTimeSeries(String name) { RTimeSeries timeSeries = new RedissonTimeSeries(evictionScheduler, commandExecutor, name); @@ -483,6 +766,15 @@ public class RedissonReactive implements RedissonReactiveClient { new RedissonTimeSeriesReactive(timeSeries, this), RTimeSeriesReactive.class); } + @Override + public RTimeSeriesReactive getTimeSeries(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + RTimeSeries timeSeries = new RedissonTimeSeries<>(params.getCodec(), evictionScheduler, ca, params.getName()); + return ReactiveProxyBuilder.create(commandExecutor, timeSeries, + new RedissonTimeSeriesReactive(timeSeries, this), RTimeSeriesReactive.class); + } + @Override public RSetCacheReactive getSetCache(String name) { RSetCache set = new RedissonSetCache(evictionScheduler, commandExecutor, name, null); @@ -497,16 +789,40 @@ public class RedissonReactive implements RedissonReactiveClient { new RedissonSetCacheReactive(set, this), RSetCacheReactive.class); } + @Override + public RSetCacheReactive getSetCache(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + RSetCache set = new RedissonSetCache(params.getCodec(), evictionScheduler, ca, params.getName(), null); + return ReactiveProxyBuilder.create(commandExecutor, set, + new RedissonSetCacheReactive(set, this), RSetCacheReactive.class); + } + @Override public RAtomicLongReactive getAtomicLong(String name) { return ReactiveProxyBuilder.create(commandExecutor, new RedissonAtomicLong(commandExecutor, name), RAtomicLongReactive.class); } + @Override + public RAtomicLongReactive getAtomicLong(CommonOptions options) { + CommonParams params = (CommonParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, + new RedissonAtomicLong(ca, params.getName()), RAtomicLongReactive.class); + } + @Override public RAtomicDoubleReactive getAtomicDouble(String name) { return ReactiveProxyBuilder.create(commandExecutor, new RedissonAtomicDouble(commandExecutor, name), RAtomicDoubleReactive.class); } - + + @Override + public RAtomicDoubleReactive getAtomicDouble(CommonOptions options) { + CommonParams params = (CommonParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, new RedissonAtomicDouble(ca, params.getName()), RAtomicDoubleReactive.class); + } + @Override public RRemoteService getRemoteService() { return getRemoteService("redisson_rs", connectionManager.getServiceManager().getCfg().getCodec()); @@ -531,11 +847,29 @@ public class RedissonReactive implements RedissonReactiveClient { return new RedissonRemoteService(codec, name, commandExecutor, executorId); } + @Override + public RRemoteService getRemoteService(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + String executorId = connectionManager.getServiceManager().getId(); + if (params.getCodec() != null && params.getCodec() != connectionManager.getServiceManager().getCfg().getCodec()) { + executorId = executorId + ":" + params.getName(); + } + return new RedissonRemoteService(params.getCodec(), params.getName(), ca, executorId); + } + @Override public RBitSetReactive getBitSet(String name) { return ReactiveProxyBuilder.create(commandExecutor, new RedissonBitSet(commandExecutor, name), RBitSetReactive.class); } + @Override + public RBitSetReactive getBitSet(CommonOptions options) { + CommonParams params = (CommonParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, new RedissonBitSet(ca, params.getName()), RBitSetReactive.class); + } + @Override public RFunctionReactive getFunction() { return ReactiveProxyBuilder.create(commandExecutor, new RedissonFuction(commandExecutor), RFunctionReactive.class); @@ -546,6 +880,13 @@ public class RedissonReactive implements RedissonReactiveClient { return ReactiveProxyBuilder.create(commandExecutor, new RedissonFuction(commandExecutor, codec), RFunctionReactive.class); } + @Override + public RFunctionReactive getFunction(OptionalOptions options) { + OptionalParams params = (OptionalParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, new RedissonFuction(ca, params.getCodec()), RFunctionReactive.class); + } + @Override public RScriptReactive getScript() { return ReactiveProxyBuilder.create(commandExecutor, new RedissonScript(commandExecutor), RScriptReactive.class); @@ -556,6 +897,13 @@ public class RedissonReactive implements RedissonReactiveClient { return ReactiveProxyBuilder.create(commandExecutor, new RedissonScript(commandExecutor, codec), RScriptReactive.class); } + @Override + public RScriptReactive getScript(OptionalOptions options) { + OptionalParams params = (OptionalParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, new RedissonScript(ca, params.getCodec()), RScriptReactive.class); + } + @Override public RBatchReactive createBatch(BatchOptions options) { return new RedissonBatchReactive(evictionScheduler, connectionManager, commandExecutor, options); @@ -571,6 +919,13 @@ public class RedissonReactive implements RedissonReactiveClient { return ReactiveProxyBuilder.create(commandExecutor, new RedissonKeys(commandExecutor), new RedissonKeysReactive(commandExecutor), RKeysReactive.class); } + @Override + public RKeysReactive getKeys(KeysOptions options) { + KeysParams params = (KeysParams) options; + CommandReactiveService ca = new CommandReactiveService(commandExecutor, params); + return ReactiveProxyBuilder.create(commandExecutor, new RedissonKeys(ca), new RedissonKeysReactive(ca), RKeysReactive.class); + } + @Override public Config getConfig() { return connectionManager.getServiceManager().getCfg(); @@ -650,6 +1005,38 @@ public class RedissonReactive implements RedissonReactiveClient { new RedissonMapReactive<>(map, commandExecutor), RLocalCachedMapReactive.class); } + @Override + public RLocalCachedMapReactive getLocalCachedMap(org.redisson.api.options.LocalCachedMapOptions options) { + LocalCachedMapParams params = (LocalCachedMapParams) options; + + LocalCachedMapOptions ops = LocalCachedMapOptions.defaults() + .cacheProvider(LocalCachedMapOptions.CacheProvider.valueOf(params.getCacheProvider().toString())) + .cacheSize(params.getCacheSize()) + .storeMode(LocalCachedMapOptions.StoreMode.valueOf(params.getStoreMode().toString())) + .evictionPolicy(LocalCachedMapOptions.EvictionPolicy.valueOf(params.getEvictionPolicy().toString())) + .maxIdle(params.getMaxIdleInMillis()) + .loader(params.getLoader()) + .loaderAsync(params.getLoaderAsync()) + .reconnectionStrategy(LocalCachedMapOptions.ReconnectionStrategy.valueOf(params.getReconnectionStrategy().toString())) + .storeCacheMiss(params.isStoreCacheMiss()) + .timeToLive(params.getTimeToLiveInMillis()) + .syncStrategy(LocalCachedMapOptions.SyncStrategy.valueOf(params.getSyncStrategy().toString())) + .useKeyEventsPattern(params.isUseKeyEventsPattern()) + .writer(params.getWriter()) + .writerAsync(params.getWriterAsync()) + .writeMode(MapOptions.WriteMode.valueOf(params.getWriteMode().toString())) + .writeBehindDelay(params.getWriteBehindDelay()) + .writeBehindBatchSize(params.getWriteBehindBatchSize()) + .writerRetryAttempts(params.getWriteRetryAttempts()) + .writerRetryInterval(Duration.ofMillis(params.getWriteRetryInterval())); + + CommandReactiveService ca = new CommandReactiveService(commandExecutor, params); + RMap map = new RedissonLocalCachedMap<>(params.getCodec(), ca, params.getName(), + ops, evictionScheduler, null, writeBehindService); + return ReactiveProxyBuilder.create(commandExecutor, map, + new RedissonMapReactive<>(map, ca), RLocalCachedMapReactive.class); + } + @Override public RTransactionReactive createTransaction(TransactionOptions options) { return new RedissonTransactionReactive(commandExecutor, options); @@ -669,6 +1056,15 @@ public class RedissonReactive implements RedissonReactiveClient { new RedissonBlockingDequeReactive(deque), RBlockingDequeReactive.class); } + @Override + public RBlockingDequeReactive getBlockingDeque(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + RedissonBlockingDeque deque = new RedissonBlockingDeque(params.getCodec(), ca, params.getName(), null); + return ReactiveProxyBuilder.create(commandExecutor, deque, + new RedissonBlockingDequeReactive(deque), RBlockingDequeReactive.class); + } + @Override public RTransferQueueReactive getTransferQueue(String name) { String remoteName = RedissonObject.suffixName(name, "remoteService"); @@ -687,6 +1083,17 @@ public class RedissonReactive implements RedissonReactiveClient { new RedissonTransferQueueReactive(queue), RTransferQueueReactive.class); } + @Override + public RTransferQueueReactive getTransferQueue(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ca = new CommandAsyncService(commandExecutor, params); + String remoteName = RedissonObject.suffixName(params.getName(), "remoteService"); + RRemoteService service = getRemoteService(remoteName); + RedissonTransferQueue queue = new RedissonTransferQueue(params.getCodec(), ca, params.getName(), service); + return ReactiveProxyBuilder.create(commandExecutor, queue, + new RedissonTransferQueueReactive(queue), RTransferQueueReactive.class); + } + @Override public String getId() { return commandExecutor.getServiceManager().getId(); diff --git a/redisson/src/main/java/org/redisson/RedissonRx.java b/redisson/src/main/java/org/redisson/RedissonRx.java index bdd4e32e3..53f5e9d39 100644 --- a/redisson/src/main/java/org/redisson/RedissonRx.java +++ b/redisson/src/main/java/org/redisson/RedissonRx.java @@ -16,8 +16,13 @@ package org.redisson; import org.redisson.api.*; +import org.redisson.api.LocalCachedMapOptions; +import org.redisson.api.MapCacheOptions; +import org.redisson.api.MapOptions; +import org.redisson.api.options.*; import org.redisson.client.codec.Codec; import org.redisson.codec.JsonCodec; +import org.redisson.command.CommandAsyncService; import org.redisson.config.Config; import org.redisson.config.ConfigSupport; import org.redisson.connection.ConnectionManager; @@ -25,6 +30,7 @@ import org.redisson.eviction.EvictionScheduler; import org.redisson.liveobject.core.RedissonObjectBuilder; import org.redisson.rx.*; +import java.time.Duration; import java.util.Arrays; /** @@ -79,9 +85,17 @@ public class RedissonRx implements RedissonRxClient { return RxProxyBuilder.create(commandExecutor, new RedissonStream(codec, commandExecutor, name), RStreamRx.class); } + @Override + public RStreamRx getStream(PlainOptions options) { + PlainParams params = (PlainParams) options; + + return RxProxyBuilder.create(commandExecutor, + new RedissonStream(params.getCodec(), new CommandAsyncService(commandExecutor, params), params.getName()), RStreamRx.class); + } + @Override public RSearchRx getSearch() { - return getSearch(null); + return getSearch((Codec) null); } @Override @@ -89,6 +103,13 @@ public class RedissonRx implements RedissonRxClient { return RxProxyBuilder.create(commandExecutor, new RedissonSearch(codec, commandExecutor), RSearchRx.class); } + @Override + public RSearchRx getSearch(OptionalOptions options) { + OptionalParams params = (OptionalParams) options; + return RxProxyBuilder.create(commandExecutor, + new RedissonSearch(params.getCodec(), new CommandAsyncService(commandExecutor, params)), RSearchRx.class); + } + @Override public RGeoRx getGeo(String name) { RedissonScoredSortedSet set = new RedissonScoredSortedSet(commandExecutor, name, null); @@ -102,17 +123,40 @@ public class RedissonRx implements RedissonRxClient { return RxProxyBuilder.create(commandExecutor, new RedissonGeo(codec, commandExecutor, name, null), new RedissonScoredSortedSetRx(set), RGeoRx.class); } - + + @Override + public RGeoRx getGeo(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + RedissonScoredSortedSet set = new RedissonScoredSortedSet(params.getCodec(), ce, params.getName(), null); + return RxProxyBuilder.create(commandExecutor, new RedissonGeo(params.getCodec(), ce, params.getName(), null), + new RedissonScoredSortedSetRx(set), RGeoRx.class); + } + @Override public RLockRx getFairLock(String name) { return RxProxyBuilder.create(commandExecutor, new RedissonFairLock(commandExecutor, name), RLockRx.class); } - + + @Override + public RLockRx getFairLock(CommonOptions options) { + CommonParams params = (CommonParams) options; + return RxProxyBuilder.create(commandExecutor, + new RedissonFairLock(new CommandAsyncService(commandExecutor, params), params.getName()), RLockRx.class); + } + @Override public RRateLimiterRx getRateLimiter(String name) { return RxProxyBuilder.create(commandExecutor, new RedissonRateLimiter(commandExecutor, name), RRateLimiterRx.class); } - + + @Override + public RRateLimiterRx getRateLimiter(CommonOptions options) { + CommonParams params = (CommonParams) options; + return RxProxyBuilder.create(commandExecutor, + new RedissonRateLimiter(new CommandAsyncService(commandExecutor, params), params.getName()), RRateLimiterRx.class); + } + @Override public RBinaryStreamRx getBinaryStream(String name) { RedissonBinaryStream stream = new RedissonBinaryStream(commandExecutor, name); @@ -120,26 +164,64 @@ public class RedissonRx implements RedissonRxClient { new RedissonBinaryStreamRx(commandExecutor, stream), RBinaryStreamRx.class); } + @Override + public RBinaryStreamRx getBinaryStream(CommonOptions options) { + CommonParams params = (CommonParams) options; + CommandRxService ce = new CommandRxService(commandExecutor, params); + RedissonBinaryStream stream = new RedissonBinaryStream(ce, params.getName()); + return RxProxyBuilder.create(commandExecutor, stream, + new RedissonBinaryStreamRx(ce, stream), RBinaryStreamRx.class); + } + @Override public RSemaphoreRx getSemaphore(String name) { return RxProxyBuilder.create(commandExecutor, new RedissonSemaphore(commandExecutor, name), RSemaphoreRx.class); } + @Override + public RSemaphoreRx getSemaphore(CommonOptions options) { + CommonParams params = (CommonParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + return RxProxyBuilder.create(commandExecutor, new RedissonSemaphore(ce, params.getName()), RSemaphoreRx.class); + } + @Override public RPermitExpirableSemaphoreRx getPermitExpirableSemaphore(String name) { return RxProxyBuilder.create(commandExecutor, new RedissonPermitExpirableSemaphore(commandExecutor, name), RPermitExpirableSemaphoreRx.class); } + @Override + public RPermitExpirableSemaphoreRx getPermitExpirableSemaphore(CommonOptions options) { + CommonParams params = (CommonParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + return RxProxyBuilder.create(commandExecutor, + new RedissonPermitExpirableSemaphore(ce, params.getName()), RPermitExpirableSemaphoreRx.class); + } + @Override public RReadWriteLockRx getReadWriteLock(String name) { return new RedissonReadWriteLockRx(commandExecutor, name); } + @Override + public RReadWriteLockRx getReadWriteLock(CommonOptions options) { + CommonParams params = (CommonParams) options; + CommandRxService ce = new CommandRxService(commandExecutor, params); + return new RedissonReadWriteLockRx(ce, params.getName()); + } + @Override public RLockRx getLock(String name) { return RxProxyBuilder.create(commandExecutor, new RedissonLock(commandExecutor, name), RLockRx.class); } + @Override + public RLockRx getLock(CommonOptions options) { + CommonParams params = (CommonParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + return RxProxyBuilder.create(commandExecutor, new RedissonLock(ce, params.getName()), RLockRx.class); + } + @Override public RLockRx getSpinLock(String name) { return getSpinLock(name, LockOptions.defaults()); @@ -157,6 +239,14 @@ public class RedissonRx implements RedissonRxClient { return RxProxyBuilder.create(commandExecutor, lock, RFencedLockRx.class); } + @Override + public RFencedLockRx getFencedLock(CommonOptions options) { + CommonParams params = (CommonParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + RedissonFencedLock lock = new RedissonFencedLock(ce, params.getName()); + return RxProxyBuilder.create(commandExecutor, lock, RFencedLockRx.class); + } + @Override public RLockRx getMultiLock(RLockRx... locks) { RLock[] ls = Arrays.stream(locks) @@ -180,6 +270,13 @@ public class RedissonRx implements RedissonRxClient { return RxProxyBuilder.create(commandExecutor, new RedissonCountDownLatch(commandExecutor, name), RCountDownLatchRx.class); } + @Override + public RCountDownLatchRx getCountDownLatch(CommonOptions options) { + CommonParams params = (CommonParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + return RxProxyBuilder.create(commandExecutor, new RedissonCountDownLatch(ce, params.getName()), RCountDownLatchRx.class); + } + @Override public RMapCacheRx getMapCache(String name, Codec codec) { RMap map = new RedissonMapCache(codec, evictionScheduler, commandExecutor, name, null, null, null); @@ -194,6 +291,31 @@ public class RedissonRx implements RedissonRxClient { new RedissonMapCacheRx(map, commandExecutor), RMapCacheRx.class); } + @Override + public RMapCacheRx getMapCache(org.redisson.api.options.MapCacheOptions options) { + MapCacheParams params = (MapCacheParams) options; + MapCacheOptions ops = MapCacheOptions.defaults() + .loader(params.getLoader()) + .loaderAsync(params.getLoaderAsync()) + .writer(params.getWriter()) + .writerAsync(params.getWriterAsync()) + .writeMode(MapOptions.WriteMode.valueOf(params.getWriteMode().toString())) + .writeBehindDelay(params.getWriteBehindDelay()) + .writeBehindBatchSize(params.getWriteBehindBatchSize()) + .writerRetryAttempts(params.getWriteRetryAttempts()) + .writerRetryInterval(Duration.ofMillis(params.getWriteRetryInterval())); + + if (params.isRemoveEmptyEvictionTask()) { + ops.removeEmptyEvictionTask(); + } + + CommandRxService ce = new CommandRxService(commandExecutor, params); + RedissonMapCache map = new RedissonMapCache<>(params.getCodec(), evictionScheduler, + ce, params.getName(), null, ops, writeBehindService); + return RxProxyBuilder.create(commandExecutor, map, + new RedissonMapCacheRx(map, ce), RMapCacheRx.class); + } + @Override public RBucketRx getBucket(String name) { return RxProxyBuilder.create(commandExecutor, new RedissonBucket(commandExecutor, name), RBucketRx.class); @@ -204,6 +326,14 @@ public class RedissonRx implements RedissonRxClient { return RxProxyBuilder.create(commandExecutor, new RedissonBucket(codec, commandExecutor, name), RBucketRx.class); } + @Override + public RBucketRx getBucket(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandRxService ce = new CommandRxService(commandExecutor, params); + return RxProxyBuilder.create(commandExecutor, + new RedissonBucket(params.getCodec(), ce, params.getName()), RBucketRx.class); + } + @Override public RBucketsRx getBuckets() { return RxProxyBuilder.create(commandExecutor, new RedissonBuckets(commandExecutor), RBucketsRx.class); @@ -214,11 +344,25 @@ public class RedissonRx implements RedissonRxClient { return RxProxyBuilder.create(commandExecutor, new RedissonBuckets(codec, commandExecutor), RBucketsRx.class); } + @Override + public RBucketsRx getBuckets(OptionalOptions options) { + OptionalParams params = (OptionalParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + return RxProxyBuilder.create(commandExecutor, new RedissonBuckets(params.getCodec(), ce), RBucketsRx.class); + } + @Override public RJsonBucketRx getJsonBucket(String name, JsonCodec codec) { return RxProxyBuilder.create(commandExecutor, new RedissonJsonBucket<>(codec, commandExecutor, name), RJsonBucketRx.class); } + @Override + public RJsonBucketRx getJsonBucket(JsonBucketOptions options) { + JsonBucketParams params = (JsonBucketParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + return RxProxyBuilder.create(commandExecutor, new RedissonJsonBucket<>(params.getCodec(), ce, params.getName()), RJsonBucketRx.class); + } + @Override public RHyperLogLogRx getHyperLogLog(String name) { return RxProxyBuilder.create(commandExecutor, new RedissonHyperLogLog(commandExecutor, name), RHyperLogLogRx.class); @@ -229,11 +373,25 @@ public class RedissonRx implements RedissonRxClient { return RxProxyBuilder.create(commandExecutor, new RedissonHyperLogLog(codec, commandExecutor, name), RHyperLogLogRx.class); } + @Override + public RHyperLogLogRx getHyperLogLog(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + return RxProxyBuilder.create(commandExecutor, new RedissonHyperLogLog(params.getCodec(), ce, params.getName()), RHyperLogLogRx.class); + } + @Override public RIdGeneratorRx getIdGenerator(String name) { return RxProxyBuilder.create(commandExecutor, new RedissonIdGenerator(commandExecutor, name), RIdGeneratorRx.class); } + @Override + public RIdGeneratorRx getIdGenerator(CommonOptions options) { + CommonParams params = (CommonParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + return RxProxyBuilder.create(commandExecutor, new RedissonIdGenerator(ce, params.getName()), RIdGeneratorRx.class); + } + @Override public RListRx getList(String name) { RedissonList list = new RedissonList(commandExecutor, name, null); @@ -248,6 +406,15 @@ public class RedissonRx implements RedissonRxClient { new RedissonListRx(list), RListRx.class); } + @Override + public RListRx getList(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + RedissonList list = new RedissonList(params.getCodec(), ce, params.getName(), null); + return RxProxyBuilder.create(commandExecutor, list, + new RedissonListRx(list), RListRx.class); + } + @Override public RListMultimapRx getListMultimap(String name) { RedissonListMultimap listMultimap = new RedissonListMultimap<>(commandExecutor, name); @@ -262,6 +429,15 @@ public class RedissonRx implements RedissonRxClient { new RedissonListMultimapRx(listMultimap, commandExecutor), RListMultimapRx.class); } + @Override + public RListMultimapRx getListMultimap(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + RedissonListMultimap listMultimap = new RedissonListMultimap<>(params.getCodec(), ce, params.getName()); + return RxProxyBuilder.create(commandExecutor, listMultimap, + new RedissonListMultimapRx(listMultimap, commandExecutor), RListMultimapRx.class); + } + @Override public RListMultimapCacheRx getListMultimapCache(String name) { RedissonListMultimapCache listMultimap = new RedissonListMultimapCache<>(evictionScheduler, commandExecutor, name); @@ -276,6 +452,15 @@ public class RedissonRx implements RedissonRxClient { new RedissonListMultimapCacheRx(listMultimap, commandExecutor), RListMultimapCacheRx.class); } + @Override + public RListMultimapCacheRx getListMultimapCache(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandRxService ce = new CommandRxService(commandExecutor, params); + RedissonListMultimapCache listMultimap = new RedissonListMultimapCache<>(evictionScheduler, params.getCodec(), ce, params.getName()); + return RxProxyBuilder.create(commandExecutor, listMultimap, + new RedissonListMultimapCacheRx(listMultimap, ce), RListMultimapCacheRx.class); + } + @Override public RSetMultimapRx getSetMultimap(String name) { RedissonSetMultimap setMultimap = new RedissonSetMultimap<>(commandExecutor, name); @@ -290,6 +475,15 @@ public class RedissonRx implements RedissonRxClient { new RedissonSetMultimapRx(setMultimap, commandExecutor, this), RSetMultimapRx.class); } + @Override + public RSetMultimapRx getSetMultimap(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandRxService ce = new CommandRxService(commandExecutor, params); + RedissonSetMultimap setMultimap = new RedissonSetMultimap<>(params.getCodec(), ce, params.getName()); + return RxProxyBuilder.create(commandExecutor, setMultimap, + new RedissonSetMultimapRx<>(setMultimap, ce, this), RSetMultimapRx.class); + } + @Override public RSetMultimapCacheRx getSetMultimapCache(String name) { RedissonSetMultimapCache setMultimap = new RedissonSetMultimapCache<>(evictionScheduler, commandExecutor, name); @@ -304,6 +498,15 @@ public class RedissonRx implements RedissonRxClient { new RedissonSetMultimapCacheRx(setMultimap, commandExecutor, this), RSetMultimapCacheRx.class); } + @Override + public RSetMultimapCacheRx getSetMultimapCache(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandRxService ce = new CommandRxService(commandExecutor, params); + RedissonSetMultimapCache setMultimap = new RedissonSetMultimapCache<>(evictionScheduler, params.getCodec(), ce, params.getName()); + return RxProxyBuilder.create(commandExecutor, setMultimap, + new RedissonSetMultimapCacheRx<>(setMultimap, ce, this), RSetMultimapCacheRx.class); + } + @Override public RMapRx getMap(String name) { RedissonMap map = new RedissonMap(commandExecutor, name, null, null, null); @@ -318,6 +521,15 @@ public class RedissonRx implements RedissonRxClient { new RedissonMapRx(map, commandExecutor), RMapRx.class); } + @Override + public RMapRx getMap(org.redisson.api.options.MapOptions options) { + MapParams params = (MapParams) options; + CommandRxService ce = new CommandRxService(commandExecutor, params); + RedissonMap map = new RedissonMap<>(params.getCodec(), ce, params.getName(), null, null, writeBehindService); + return RxProxyBuilder.create(commandExecutor, map, + new RedissonMapRx<>(map, ce), RMapRx.class); + } + @Override public RSetRx getSet(String name) { RedissonSet set = new RedissonSet(commandExecutor, name, null); @@ -332,6 +544,15 @@ public class RedissonRx implements RedissonRxClient { new RedissonSetRx(set, this), RSetRx.class); } + @Override + public RSetRx getSet(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + RedissonSet set = new RedissonSet(params.getCodec(), ce, params.getName(), null); + return RxProxyBuilder.create(commandExecutor, set, + new RedissonSetRx(set, this), RSetRx.class); + } + @Override public RScoredSortedSetRx getScoredSortedSet(String name) { RedissonScoredSortedSet set = new RedissonScoredSortedSet(commandExecutor, name, null); @@ -346,6 +567,15 @@ public class RedissonRx implements RedissonRxClient { new RedissonScoredSortedSetRx(set), RScoredSortedSetRx.class); } + @Override + public RScoredSortedSetRx getScoredSortedSet(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + RedissonScoredSortedSet set = new RedissonScoredSortedSet(params.getCodec(), ce, params.getName(), null); + return RxProxyBuilder.create(commandExecutor, set, + new RedissonScoredSortedSetRx<>(set), RScoredSortedSetRx.class); + } + @Override public RLexSortedSetRx getLexSortedSet(String name) { RedissonLexSortedSet set = new RedissonLexSortedSet(commandExecutor, name, null); @@ -353,6 +583,15 @@ public class RedissonRx implements RedissonRxClient { new RedissonLexSortedSetRx(set), RLexSortedSetRx.class); } + @Override + public RLexSortedSetRx getLexSortedSet(CommonOptions options) { + CommonParams params = (CommonParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + RedissonLexSortedSet set = new RedissonLexSortedSet(ce, params.getName(), null); + return RxProxyBuilder.create(commandExecutor, set, + new RedissonLexSortedSetRx(set), RLexSortedSetRx.class); + } + @Override public RShardedTopicRx getShardedTopic(String name) { RShardedTopic topic = new RedissonShardedTopic(commandExecutor, name); @@ -365,6 +604,14 @@ public class RedissonRx implements RedissonRxClient { return RxProxyBuilder.create(commandExecutor, topic, new RedissonTopicRx(topic), RShardedTopicRx.class); } + @Override + public RShardedTopicRx getShardedTopic(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + RShardedTopic topic = new RedissonShardedTopic(params.getCodec(), ce, params.getName()); + return RxProxyBuilder.create(commandExecutor, topic, new RedissonTopicRx(topic), RShardedTopicRx.class); + } + @Override public RTopicRx getTopic(String name) { RTopic topic = new RedissonTopic(commandExecutor, name); @@ -377,6 +624,14 @@ public class RedissonRx implements RedissonRxClient { return RxProxyBuilder.create(commandExecutor, topic, new RedissonTopicRx(topic), RTopicRx.class); } + @Override + public RTopicRx getTopic(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + RTopic topic = new RedissonTopic(params.getCodec(), ce, params.getName()); + return RxProxyBuilder.create(commandExecutor, topic, new RedissonTopicRx(topic), RTopicRx.class); + } + @Override public RReliableTopicRx getReliableTopic(String name) { return RxProxyBuilder.create(commandExecutor, new RedissonReliableTopic(commandExecutor, name, null), RReliableTopicRx.class); @@ -387,6 +642,14 @@ public class RedissonRx implements RedissonRxClient { return RxProxyBuilder.create(commandExecutor, new RedissonReliableTopic(codec, commandExecutor, name, null), RReliableTopicRx.class); } + @Override + public RReliableTopicRx getReliableTopic(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + return RxProxyBuilder.create(commandExecutor, + new RedissonReliableTopic(params.getCodec(), ce, params.getName(), null), RReliableTopicRx.class); + } + @Override public RPatternTopicRx getPatternTopic(String pattern) { return RxProxyBuilder.create(commandExecutor, new RedissonPatternTopic(commandExecutor, pattern), RPatternTopicRx.class); @@ -397,6 +660,13 @@ public class RedissonRx implements RedissonRxClient { return RxProxyBuilder.create(commandExecutor, new RedissonPatternTopic(codec, commandExecutor, pattern), RPatternTopicRx.class); } + @Override + public RPatternTopicRx getPatternTopic(PatternTopicOptions options) { + PatternTopicParams params = (PatternTopicParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + return RxProxyBuilder.create(commandExecutor, new RedissonPatternTopic(params.getCodec(), ce, params.getPattern()), RPatternTopicRx.class); + } + @Override public RQueueRx getQueue(String name) { return RxProxyBuilder.create(commandExecutor, new RedissonQueue(commandExecutor, name, null), @@ -409,6 +679,14 @@ public class RedissonRx implements RedissonRxClient { new RedissonListRx(new RedissonList(codec, commandExecutor, name, null)), RQueueRx.class); } + @Override + public RQueueRx getQueue(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + return RxProxyBuilder.create(commandExecutor, new RedissonQueue(params.getCodec(), ce, params.getName(), null), + new RedissonListRx(new RedissonList(params.getCodec(), ce, params.getName(), null)), RQueueRx.class); + } + @Override public RRingBufferRx getRingBuffer(String name) { return RxProxyBuilder.create(commandExecutor, new RedissonRingBuffer(commandExecutor, name, null), RRingBufferRx.class); @@ -419,6 +697,14 @@ public class RedissonRx implements RedissonRxClient { return RxProxyBuilder.create(commandExecutor, new RedissonRingBuffer(codec, commandExecutor, name, null), RRingBufferRx.class); } + @Override + public RRingBufferRx getRingBuffer(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + return RxProxyBuilder.create(commandExecutor, + new RedissonRingBuffer(params.getCodec(), ce, params.getName(), null), RRingBufferRx.class); + } + @Override public RBlockingQueueRx getBlockingQueue(String name) { RedissonBlockingQueue queue = new RedissonBlockingQueue(commandExecutor, name, null); @@ -433,6 +719,15 @@ public class RedissonRx implements RedissonRxClient { new RedissonBlockingQueueRx(queue), RBlockingQueueRx.class); } + @Override + public RBlockingQueueRx getBlockingQueue(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + RedissonBlockingQueue queue = new RedissonBlockingQueue(params.getCodec(), ce, params.getName(), null); + return RxProxyBuilder.create(commandExecutor, queue, + new RedissonBlockingQueueRx(queue), RBlockingQueueRx.class); + } + @Override public RDequeRx getDeque(String name) { RedissonDeque queue = new RedissonDeque(commandExecutor, name, null); @@ -447,6 +742,15 @@ public class RedissonRx implements RedissonRxClient { new RedissonListRx(queue), RDequeRx.class); } + @Override + public RDequeRx getDeque(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + RedissonDeque queue = new RedissonDeque(params.getCodec(), ce, params.getName(), null); + return RxProxyBuilder.create(commandExecutor, queue, + new RedissonListRx(queue), RDequeRx.class); + } + @Override public RTimeSeriesRx getTimeSeries(String name) { RTimeSeries timeSeries = new RedissonTimeSeries(evictionScheduler, commandExecutor, name); @@ -461,6 +765,15 @@ public class RedissonRx implements RedissonRxClient { new RedissonTimeSeriesRx(timeSeries, this), RTimeSeriesRx.class); } + @Override + public RTimeSeriesRx getTimeSeries(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + RTimeSeries timeSeries = new RedissonTimeSeries<>(params.getCodec(), evictionScheduler, ce, params.getName()); + return RxProxyBuilder.create(commandExecutor, timeSeries, + new RedissonTimeSeriesRx<>(timeSeries, this), RTimeSeriesRx.class); + } + @Override public RSetCacheRx getSetCache(String name) { RSetCache set = new RedissonSetCache(evictionScheduler, commandExecutor, name, null); @@ -475,16 +788,39 @@ public class RedissonRx implements RedissonRxClient { new RedissonSetCacheRx(set, this), RSetCacheRx.class); } + @Override + public RSetCacheRx getSetCache(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + RSetCache set = new RedissonSetCache(params.getCodec(), evictionScheduler, ce, params.getName(), null); + return RxProxyBuilder.create(commandExecutor, set, + new RedissonSetCacheRx(set, this), RSetCacheRx.class); + } + @Override public RAtomicLongRx getAtomicLong(String name) { return RxProxyBuilder.create(commandExecutor, new RedissonAtomicLong(commandExecutor, name), RAtomicLongRx.class); } + @Override + public RAtomicLongRx getAtomicLong(CommonOptions options) { + CommonParams params = (CommonParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + return RxProxyBuilder.create(commandExecutor, new RedissonAtomicLong(ce, params.getName()), RAtomicLongRx.class); + } + @Override public RAtomicDoubleRx getAtomicDouble(String name) { return RxProxyBuilder.create(commandExecutor, new RedissonAtomicDouble(commandExecutor, name), RAtomicDoubleRx.class); } - + + @Override + public RAtomicDoubleRx getAtomicDouble(CommonOptions options) { + CommonParams params = (CommonParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + return RxProxyBuilder.create(commandExecutor, new RedissonAtomicDouble(ce, params.getName()), RAtomicDoubleRx.class); + } + @Override public RRemoteService getRemoteService() { return getRemoteService("redisson_rs", connectionManager.getServiceManager().getCfg().getCodec()); @@ -509,11 +845,29 @@ public class RedissonRx implements RedissonRxClient { return new RedissonRemoteService(codec, name, commandExecutor, executorId); } + @Override + public RRemoteService getRemoteService(PlainOptions options) { + PlainParams params = (PlainParams) options; + String executorId = connectionManager.getServiceManager().getId(); + if (params.getCodec() != null + && params.getCodec() != connectionManager.getServiceManager().getCfg().getCodec()) { + executorId = executorId + ":" + params.getName(); + } + return new RedissonRemoteService(params.getCodec(), params.getName(), commandExecutor, executorId); + } + @Override public RBitSetRx getBitSet(String name) { return RxProxyBuilder.create(commandExecutor, new RedissonBitSet(commandExecutor, name), RBitSetRx.class); } + @Override + public RBitSetRx getBitSet(CommonOptions options) { + CommonParams params = (CommonParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + return RxProxyBuilder.create(commandExecutor, new RedissonBitSet(ce, params.getName()), RBitSetRx.class); + } + @Override public RFunctionRx getFunction() { return RxProxyBuilder.create(commandExecutor, new RedissonFuction(commandExecutor), RFunctionRx.class); @@ -524,6 +878,13 @@ public class RedissonRx implements RedissonRxClient { return RxProxyBuilder.create(commandExecutor, new RedissonFuction(commandExecutor, codec), RFunctionRx.class); } + @Override + public RFunctionRx getFunction(OptionalOptions options) { + OptionalParams params = (OptionalParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + return RxProxyBuilder.create(commandExecutor, new RedissonFuction(ce, params.getCodec()), RFunctionRx.class); + } + @Override public RScriptRx getScript() { return RxProxyBuilder.create(commandExecutor, new RedissonScript(commandExecutor), RScriptRx.class); @@ -534,6 +895,13 @@ public class RedissonRx implements RedissonRxClient { return RxProxyBuilder.create(commandExecutor, new RedissonScript(commandExecutor, codec), RScriptRx.class); } + @Override + public RScriptRx getScript(OptionalOptions options) { + OptionalParams params = (OptionalParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + return RxProxyBuilder.create(commandExecutor, new RedissonScript(ce, params.getCodec()), RScriptRx.class); + } + @Override public RBatchRx createBatch() { return createBatch(BatchOptions.defaults()); @@ -549,6 +917,13 @@ public class RedissonRx implements RedissonRxClient { return RxProxyBuilder.create(commandExecutor, new RedissonKeys(commandExecutor), new RedissonKeysRx(commandExecutor), RKeysRx.class); } + @Override + public RKeysRx getKeys(KeysOptions options) { + KeysParams params = (KeysParams) options; + CommandRxService ce = new CommandRxService(commandExecutor, params); + return RxProxyBuilder.create(commandExecutor, new RedissonKeys(ce), new RedissonKeysRx(ce), RKeysRx.class); + } + @Override public Config getConfig() { return connectionManager.getServiceManager().getCfg(); @@ -627,6 +1002,39 @@ public class RedissonRx implements RedissonRxClient { new RedissonMapRx<>(map, commandExecutor), RLocalCachedMapRx.class); } + @Override + public RLocalCachedMapRx getLocalCachedMap(org.redisson.api.options.LocalCachedMapOptions options) { + LocalCachedMapParams params = (LocalCachedMapParams) options; + + LocalCachedMapOptions ops = LocalCachedMapOptions.defaults() + .cacheProvider(LocalCachedMapOptions.CacheProvider.valueOf(params.getCacheProvider().toString())) + .cacheSize(params.getCacheSize()) + .storeMode(LocalCachedMapOptions.StoreMode.valueOf(params.getStoreMode().toString())) + .evictionPolicy(LocalCachedMapOptions.EvictionPolicy.valueOf(params.getEvictionPolicy().toString())) + .maxIdle(params.getMaxIdleInMillis()) + .loader(params.getLoader()) + .loaderAsync(params.getLoaderAsync()) + .reconnectionStrategy(LocalCachedMapOptions.ReconnectionStrategy.valueOf(params.getReconnectionStrategy().toString())) + .storeCacheMiss(params.isStoreCacheMiss()) + .timeToLive(params.getTimeToLiveInMillis()) + .syncStrategy(LocalCachedMapOptions.SyncStrategy.valueOf(params.getSyncStrategy().toString())) + .useKeyEventsPattern(params.isUseKeyEventsPattern()) + .writer(params.getWriter()) + .writerAsync(params.getWriterAsync()) + .writeMode(MapOptions.WriteMode.valueOf(params.getWriteMode().toString())) + .writeBehindDelay(params.getWriteBehindDelay()) + .writeBehindBatchSize(params.getWriteBehindBatchSize()) + .writerRetryAttempts(params.getWriteRetryAttempts()) + .writerRetryInterval(Duration.ofMillis(params.getWriteRetryInterval())); + + CommandRxService ce = new CommandRxService(commandExecutor, params); + RMap map = new RedissonLocalCachedMap<>(params.getCodec(), ce, params.getName(), + ops, evictionScheduler, null, writeBehindService); + + return RxProxyBuilder.create(commandExecutor, map, + new RedissonMapRx<>(map, ce), RLocalCachedMapRx.class); + } + @Override public RTransactionRx createTransaction(TransactionOptions options) { return new RedissonTransactionRx(commandExecutor, options); @@ -646,6 +1054,15 @@ public class RedissonRx implements RedissonRxClient { new RedissonBlockingDequeRx(deque), RBlockingDequeRx.class); } + @Override + public RBlockingDequeRx getBlockingDeque(PlainOptions options) { + PlainParams params = (PlainParams) options; + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + RedissonBlockingDeque deque = new RedissonBlockingDeque(params.getCodec(), ce, params.getName(), null); + return RxProxyBuilder.create(commandExecutor, deque, + new RedissonBlockingDequeRx(deque), RBlockingDequeRx.class); + } + @Override public RTransferQueueRx getTransferQueue(String name) { String remoteName = RedissonObject.suffixName(name, "remoteService"); @@ -664,6 +1081,17 @@ public class RedissonRx implements RedissonRxClient { new RedissonTransferQueueRx(queue), RTransferQueueRx.class); } + @Override + public RTransferQueueRx getTransferQueue(PlainOptions options) { + PlainParams params = (PlainParams) options; + String remoteName = RedissonObject.suffixName(params.getName(), "remoteService"); + RRemoteService service = getRemoteService(remoteName); + CommandAsyncService ce = new CommandAsyncService(commandExecutor, params); + RedissonTransferQueue queue = new RedissonTransferQueue(params.getCodec(), ce, params.getName(), service); + return RxProxyBuilder.create(commandExecutor, queue, + new RedissonTransferQueueRx(queue), RTransferQueueRx.class); + } + @Override public String getId() { return commandExecutor.getServiceManager().getId(); diff --git a/redisson/src/main/java/org/redisson/RedissonScript.java b/redisson/src/main/java/org/redisson/RedissonScript.java index d4b6fa901..e44b5028b 100644 --- a/redisson/src/main/java/org/redisson/RedissonScript.java +++ b/redisson/src/main/java/org/redisson/RedissonScript.java @@ -45,7 +45,7 @@ public class RedissonScript implements RScript { public RedissonScript(CommandAsyncExecutor commandExecutor, Codec codec) { this.commandExecutor = commandExecutor; - this.codec = codec; + this.codec = commandExecutor.getServiceManager().getCodec(codec); } @Override diff --git a/redisson/src/main/java/org/redisson/RedissonSearch.java b/redisson/src/main/java/org/redisson/RedissonSearch.java index a02daacc9..55caa4236 100644 --- a/redisson/src/main/java/org/redisson/RedissonSearch.java +++ b/redisson/src/main/java/org/redisson/RedissonSearch.java @@ -51,11 +51,7 @@ public class RedissonSearch implements RSearch { private final CommandAsyncExecutor commandExecutor; public RedissonSearch(Codec codec, CommandAsyncExecutor commandExecutor) { - if (codec == null) { - this.codec = commandExecutor.getServiceManager().getCfg().getCodec(); - } else { - this.codec = codec; - } + this.codec = commandExecutor.getServiceManager().getCodec(codec); this.commandExecutor = commandExecutor; } diff --git a/redisson/src/main/java/org/redisson/RedissonTopic.java b/redisson/src/main/java/org/redisson/RedissonTopic.java index ed227acda..e07d496f9 100644 --- a/redisson/src/main/java/org/redisson/RedissonTopic.java +++ b/redisson/src/main/java/org/redisson/RedissonTopic.java @@ -71,7 +71,7 @@ public class RedissonTopic implements RTopic { this.commandExecutor = commandExecutor; this.name = nameMapper.map(name); this.channelName = new ChannelName(this.name); - this.codec = codec; + this.codec = commandExecutor.getServiceManager().getCodec(codec); this.subscribeService = commandExecutor.getConnectionManager().getSubscribeService(); } diff --git a/redisson/src/main/java/org/redisson/api/ExecutorOptions.java b/redisson/src/main/java/org/redisson/api/ExecutorOptions.java index 9354e9891..6a3110e58 100644 --- a/redisson/src/main/java/org/redisson/api/ExecutorOptions.java +++ b/redisson/src/main/java/org/redisson/api/ExecutorOptions.java @@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit; * @author Nikita Koksharov * */ +@Deprecated public final class ExecutorOptions { private long taskRetryInterval = 5 * 60000; diff --git a/redisson/src/main/java/org/redisson/api/LocalCachedMapOptions.java b/redisson/src/main/java/org/redisson/api/LocalCachedMapOptions.java index 97a212d0a..29615218a 100644 --- a/redisson/src/main/java/org/redisson/api/LocalCachedMapOptions.java +++ b/redisson/src/main/java/org/redisson/api/LocalCachedMapOptions.java @@ -15,6 +15,7 @@ */ package org.redisson.api; +import java.time.Duration; import java.util.concurrent.TimeUnit; import org.redisson.api.map.MapLoader; @@ -30,6 +31,7 @@ import org.redisson.api.map.MapWriter; * @param key type * @param value type */ +@Deprecated public class LocalCachedMapOptions extends MapOptions { /** @@ -428,4 +430,14 @@ public class LocalCachedMapOptions extends MapOptions { public LocalCachedMapOptions loaderAsync(MapLoaderAsync loaderAsync) { return (LocalCachedMapOptions) super.loaderAsync(loaderAsync); } + + @Override + public LocalCachedMapOptions writerRetryAttempts(int writerRetryAttempts) { + return (LocalCachedMapOptions) super.writerRetryAttempts(writerRetryAttempts); + } + + @Override + public LocalCachedMapOptions writerRetryInterval(Duration writerRetryInterval) { + return (LocalCachedMapOptions) super.writerRetryInterval(writerRetryInterval); + } } diff --git a/redisson/src/main/java/org/redisson/api/MapCacheOptions.java b/redisson/src/main/java/org/redisson/api/MapCacheOptions.java index ed5034157..8ad72e99b 100644 --- a/redisson/src/main/java/org/redisson/api/MapCacheOptions.java +++ b/redisson/src/main/java/org/redisson/api/MapCacheOptions.java @@ -20,6 +20,8 @@ import org.redisson.api.map.MapLoaderAsync; import org.redisson.api.map.MapWriter; import org.redisson.api.map.MapWriterAsync; +import java.time.Duration; + /** * Configuration for RMapCache object. * @@ -71,6 +73,16 @@ public class MapCacheOptions extends MapOptions { return (MapCacheOptions) super.loaderAsync(loaderAsync); } + @Override + public MapCacheOptions writerRetryAttempts(int writerRetryAttempts) { + return (MapCacheOptions) super.writerRetryAttempts(writerRetryAttempts); + } + + @Override + public MapCacheOptions writerRetryInterval(Duration writerRetryInterval) { + return (MapCacheOptions) super.writerRetryInterval(writerRetryInterval); + } + public boolean isRemoveEmptyEvictionTask() { return removeEmptyEvictionTask; } diff --git a/redisson/src/main/java/org/redisson/api/MapOptions.java b/redisson/src/main/java/org/redisson/api/MapOptions.java index f0a4b272a..e9f064a67 100644 --- a/redisson/src/main/java/org/redisson/api/MapOptions.java +++ b/redisson/src/main/java/org/redisson/api/MapOptions.java @@ -32,6 +32,7 @@ import java.time.Duration; * @param key type * @param value type */ +@Deprecated public class MapOptions { public enum WriteMode { diff --git a/redisson/src/main/java/org/redisson/api/RedissonClient.java b/redisson/src/main/java/org/redisson/api/RedissonClient.java index afe35168c..b5f658cbe 100755 --- a/redisson/src/main/java/org/redisson/api/RedissonClient.java +++ b/redisson/src/main/java/org/redisson/api/RedissonClient.java @@ -15,6 +15,7 @@ */ package org.redisson.api; +import org.redisson.api.options.*; import org.redisson.api.redisnode.BaseRedisNodes; import org.redisson.api.redisnode.RedisNodes; import org.redisson.client.codec.Codec; @@ -40,7 +41,7 @@ public interface RedissonClient { * * @param value type * @param label type - * @param name - name of instance + * @param name name of instance * @return RTimeSeries object */ RTimeSeries getTimeSeries(String name); @@ -51,12 +52,22 @@ public interface RedissonClient { * * @param value type * @param label type - * @param name - name of instance - * @param codec - codec for values + * @param name name of instance + * @param codec codec for values * @return RTimeSeries object */ RTimeSeries getTimeSeries(String name, Codec codec); + /** + * Returns time-series instance with specified options. + * + * @param value type + * @param label type + * @param options instance options + * @return RTimeSeries object + */ + RTimeSeries getTimeSeries(PlainOptions options); + /** * Returns stream instance by name *

@@ -77,12 +88,24 @@ public interface RedissonClient { * * @param type of key * @param type of value - * @param name - name of stream - * @param codec - codec for entry + * @param name name of stream + * @param codec codec for entry * @return RStream object */ RStream getStream(String name, Codec codec); + /** + * Returns time-series instance with specified options. + *

+ * Requires Redis 5.0.0 and higher. + * + * @param type of key + * @param type of value + * @param options instance options + * @return RStream object + */ + RStream getStream(PlainOptions options); + /** * Returns API for RediSearch module * @@ -93,10 +116,19 @@ public interface RedissonClient { /** * Returns API for RediSearch module using defined codec for attribute values. * + * @param codec codec for entry * @return RSearch object */ RSearch getSearch(Codec codec); + /** + * Returns API for RediSearch module with specified options. + * + * @param options instance options + * @return RSearch object + */ + RSearch getSearch(OptionalOptions options); + /** * Returns rate limiter instance by name * @@ -104,6 +136,14 @@ public interface RedissonClient { * @return RateLimiter object */ RRateLimiter getRateLimiter(String name); + + /** + * Returns rate limiter instance with specified options. + * + * @param options instance options + * @return RateLimiter object + */ + RRateLimiter getRateLimiter(CommonOptions options); /** * Returns binary stream holder instance by name @@ -112,12 +152,20 @@ public interface RedissonClient { * @return BinaryStream object */ RBinaryStream getBinaryStream(String name); + + /** + * Returns binary stream holder instance with specified options. + * + * @param options instance options + * @return BinaryStream object + */ + RBinaryStream getBinaryStream(CommonOptions options); /** * Returns geospatial items holder instance by name. * * @param type of value - * @param name - name of object + * @param name name of object * @return Geo object */ RGeo getGeo(String name); @@ -127,11 +175,20 @@ public interface RedissonClient { * using provided codec for geospatial members. * * @param type of value - * @param name - name of object - * @param codec - codec for value + * @param name name of object + * @param codec codec for value * @return Geo object */ RGeo getGeo(String name, Codec codec); + + /** + * Returns geospatial items holder instance with specified options. + * + * @param type of value + * @param options instance options + * @return Geo object + */ + RGeo getGeo(PlainOptions options); /** * Returns set-based cache instance by name. @@ -140,7 +197,7 @@ public interface RedissonClient { *

If eviction is not required then it's better to use regular map {@link #getSet(String, Codec)}.

* * @param type of value - * @param name - name of object + * @param name name of object * @return SetCache object */ RSetCache getSetCache(String name); @@ -152,12 +209,24 @@ public interface RedissonClient { *

If eviction is not required then it's better to use regular map {@link #getSet(String, Codec)}.

* * @param type of value - * @param name - name of object - * @param codec - codec for values + * @param name name of object + * @param codec codec for values * @return SetCache object */ RSetCache getSetCache(String name, Codec codec); + /** + * Returns set-based cache instance with specified options. + * Supports value eviction with a given TTL value. + * + *

If eviction is not required then it's better to use regular map {@link #getSet(PlainOptions)}.

+ * + * @param type of value + * @param options instance options + * @return SetCache object + */ + RSetCache getSetCache(PlainOptions options); + /** * Returns map-based cache instance by name * using provided codec for both cache keys and values. @@ -167,8 +236,8 @@ public interface RedissonClient { * * @param type of key * @param type of value - * @param name - object name - * @param codec - codec for keys and values + * @param name object name + * @param codec codec for keys and values * @return MapCache object */ RMapCache getMapCache(String name, Codec codec); @@ -182,13 +251,27 @@ public interface RedissonClient { * * @param type of key * @param type of value - * @param name - object name - * @param codec - codec for keys and values - * @param options - map options + * @param name object name + * @param codec codec for keys and values + * @param options map options * @return MapCache object */ + @Deprecated RMapCache getMapCache(String name, Codec codec, MapCacheOptions options); + /** + * Returns map-based cache instance with specified options. + * Supports entry eviction with a given MaxIdleTime and TTL settings. + *

+ * If eviction is not required then it's better to use regular map {@link #getMap(org.redisson.api.options.MapOptions)}.

+ * + * @param type of key + * @param type of value + * @param options instance options + * @return MapCache object + */ + RMapCache getMapCache(org.redisson.api.options.MapCacheOptions options); + /** * Returns map-based cache instance by name. * Supports entry eviction with a given MaxIdleTime and TTL settings. @@ -197,7 +280,7 @@ public interface RedissonClient { * * @param type of key * @param type of value - * @param name - name of object + * @param name name of object * @return MapCache object */ RMapCache getMapCache(String name); @@ -210,17 +293,18 @@ public interface RedissonClient { * * @param type of key * @param type of value - * @param name - name of object - * @param options - map options + * @param name name of object + * @param options map options * @return MapCache object */ + @Deprecated RMapCache getMapCache(String name, MapCacheOptions options); /** * Returns object holder instance by name. * * @param type of value - * @param name - name of object + * @param name name of object * @return Bucket object */ RBucket getBucket(String name); @@ -230,16 +314,25 @@ public interface RedissonClient { * using provided codec for object. * * @param type of value - * @param name - name of object - * @param codec - codec for values + * @param name name of object + * @param codec codec for values * @return Bucket object */ RBucket getBucket(String name, Codec codec); + /** + * Returns object holder instance with specified options. + * + * @param type of value + * @param options instance options + * @return Bucket object + */ + RBucket getBucket(PlainOptions options); + /** * Returns interface for mass operations with Bucket objects. * - * @return Buckets + * @return Buckets object */ RBuckets getBuckets(); @@ -247,11 +340,19 @@ public interface RedissonClient { * Returns interface for mass operations with Bucket objects * using provided codec for object. * - * @param codec - codec for bucket objects - * @return Buckets + * @param codec codec for bucket objects + * @return Buckets object */ RBuckets getBuckets(Codec codec); + /** + * Returns API for mass operations over Bucket objects with specified options. + * + * @param options instance options + * @return Buckets object + */ + RBuckets getBuckets(OptionalOptions options); + /** * Returns JSON data holder instance by name using provided codec. * @@ -262,11 +363,20 @@ public interface RedissonClient { */ RJsonBucket getJsonBucket(String name, JsonCodec codec); + /** + * Returns JSON data holder instance with specified options. + * + * @param type of value + * @param options instance options + * @return JsonBucket object + */ + RJsonBucket getJsonBucket(JsonBucketOptions options); + /** * Returns HyperLogLog instance by name. * * @param type of value - * @param name - name of object + * @param name name of object * @return HyperLogLog object */ RHyperLogLog getHyperLogLog(String name); @@ -276,17 +386,26 @@ public interface RedissonClient { * using provided codec for hll objects. * * @param type of value - * @param name - name of object - * @param codec - codec for values + * @param name name of object + * @param codec codec for values * @return HyperLogLog object */ RHyperLogLog getHyperLogLog(String name, Codec codec); + /** + * Returns HyperLogLog instance with specified options. + * + * @param type of value + * @param options instance options + * @return HyperLogLog object + */ + RHyperLogLog getHyperLogLog(PlainOptions options); + /** * Returns list instance by name. * * @param type of value - * @param name - name of object + * @param name name of object * @return List object */ RList getList(String name); @@ -296,18 +415,27 @@ public interface RedissonClient { * using provided codec for list objects. * * @param type of value - * @param name - name of object - * @param codec - codec for values + * @param name name of object + * @param codec codec for values * @return List object */ RList getList(String name, Codec codec); + /** + * Returns list instance with specified options. + * + * @param type of value + * @param options instance options + * @return List object + */ + RList getList(PlainOptions options); + /** * Returns List based Multimap instance by name. * * @param type of key * @param type of value - * @param name - name of object + * @param name name of object * @return ListMultimap object */ RListMultimap getListMultimap(String name); @@ -318,12 +446,22 @@ public interface RedissonClient { * * @param type of key * @param type of value - * @param name - name of object - * @param codec - codec for keys and values + * @param name name of object + * @param codec codec for keys and values * @return ListMultimap object */ RListMultimap getListMultimap(String name, Codec codec); + /** + * Returns List based Multimap instance with specified options. + * + * @param type of key + * @param type of value + * @param options instance options + * @return ListMultimap object + */ + RListMultimap getListMultimap(PlainOptions options); + /** * Returns List based Multimap instance by name. * Supports key-entry eviction with a given TTL value. @@ -332,7 +470,7 @@ public interface RedissonClient { * * @param type of key * @param type of value - * @param name - name of object + * @param name name of object * @return ListMultimapCache object */ RListMultimapCache getListMultimapCache(String name); @@ -346,11 +484,24 @@ public interface RedissonClient { * * @param type of key * @param type of value - * @param name - name of object - * @param codec - codec for keys and values + * @param name name of object + * @param codec codec for keys and values * @return ListMultimapCache object */ RListMultimapCache getListMultimapCache(String name, Codec codec); + + /** + * Returns List based Multimap instance by name. + * Supports key-entry eviction with a given TTL value. + * + *

If eviction is not required then it's better to use regular map {@link #getSetMultimap(String)}.

+ * + * @param type of key + * @param type of value + * @param options instance options + * @return ListMultimapCache object + */ + RListMultimapCache getListMultimapCache(PlainOptions options); /** * Returns local cached map instance by name. @@ -358,10 +509,11 @@ public interface RedissonClient { * * @param type of key * @param type of value - * @param name - name of object - * @param options - local map options + * @param name name of object + * @param options local map options * @return LocalCachedMap object */ + @Deprecated RLocalCachedMap getLocalCachedMap(String name, LocalCachedMapOptions options); /** @@ -370,19 +522,30 @@ public interface RedissonClient { * * @param type of key * @param type of value - * @param name - name of object - * @param codec - codec for keys and values - * @param options - local map options + * @param name name of object + * @param codec codec for keys and values + * @param options local map options * @return LocalCachedMap object */ + @Deprecated RLocalCachedMap getLocalCachedMap(String name, Codec codec, LocalCachedMapOptions options); + + /** + * Returns local cached map instance with specified options. + * + * @param type of key + * @param type of value + * @param options instance options + * @return LocalCachedMap object + */ + RLocalCachedMap getLocalCachedMap(org.redisson.api.options.LocalCachedMapOptions options); /** * Returns map instance by name. * * @param type of key * @param type of value - * @param name - name of object + * @param name name of object * @return Map object */ RMap getMap(String name); @@ -392,10 +555,11 @@ public interface RedissonClient { * * @param type of key * @param type of value - * @param name - name of object - * @param options - map options + * @param name name of object + * @param options map options * @return Map object */ + @Deprecated RMap getMap(String name, MapOptions options); /** @@ -404,8 +568,8 @@ public interface RedissonClient { * * @param type of key * @param type of value - * @param name - name of object - * @param codec - codec for keys and values + * @param name name of object + * @param codec codec for keys and values * @return Map object */ RMap getMap(String name, Codec codec); @@ -416,19 +580,30 @@ public interface RedissonClient { * * @param type of key * @param type of value - * @param name - name of object - * @param codec - codec for keys and values - * @param options - map options + * @param name name of object + * @param codec codec for keys and values + * @param options map options * @return Map object */ + @Deprecated RMap getMap(String name, Codec codec, MapOptions options); + /** + * Returns map instance by name. + * + * @param type of key + * @param type of value + * @param options instance options + * @return Map object + */ + RMap getMap(org.redisson.api.options.MapOptions options); + /** * Returns Set based Multimap instance by name. * * @param type of key * @param type of value - * @param name - name of object + * @param name name of object * @return SetMultimap object */ RSetMultimap getSetMultimap(String name); @@ -439,12 +614,22 @@ public interface RedissonClient { * * @param type of key * @param type of value - * @param name - name of object - * @param codec - codec for keys and values + * @param name name of object + * @param codec codec for keys and values * @return SetMultimap object */ RSetMultimap getSetMultimap(String name, Codec codec); + /** + * Returns Set based Multimap instance with specified options. + * + * @param type of key + * @param type of value + * @param options instance options + * @return SetMultimap object + */ + RSetMultimap getSetMultimap(PlainOptions options); + /** * Returns Set based Multimap instance by name. * Supports key-entry eviction with a given TTL value. @@ -453,7 +638,7 @@ public interface RedissonClient { * * @param type of key * @param type of value - * @param name - name of object + * @param name name of object * @return SetMultimapCache object */ RSetMultimapCache getSetMultimapCache(String name); @@ -467,29 +652,59 @@ public interface RedissonClient { * * @param type of key * @param type of value - * @param name - name of object - * @param codec - codec for keys and values + * @param name name of object + * @param codec codec for keys and values * @return SetMultimapCache object */ RSetMultimapCache getSetMultimapCache(String name, Codec codec); + /** + * Returns Set based Multimap instance with specified options. + * Supports key-entry eviction with a given TTL value. + * + *

If eviction is not required then it's better to use regular map {@link #getSetMultimap(PlainOptions)}.

+ * + * @param type of key + * @param type of value + * @param options instance options + * @return SetMultimapCache object + */ + RSetMultimapCache getSetMultimapCache(PlainOptions options); + /** * Returns semaphore instance by name * - * @param name - name of object + * @param name name of object * @return Semaphore object */ RSemaphore getSemaphore(String name); + + /** + * Returns semaphore instance with specified options. + * + * @param options instance options + * @return Semaphore object + */ + RSemaphore getSemaphore(CommonOptions options); /** * Returns semaphore instance by name. * Supports lease time parameter for each acquired permit. * - * @param name - name of object + * @param name name of object * @return PermitExpirableSemaphore object */ RPermitExpirableSemaphore getPermitExpirableSemaphore(String name); + /** + * Returns semaphore instance with specified options. + * Supports lease time parameter for each acquired permit. + * + * @param options instance options + * @return PermitExpirableSemaphore object + */ + RPermitExpirableSemaphore getPermitExpirableSemaphore(CommonOptions options); + /** * Returns Lock instance by name. *

@@ -497,11 +712,23 @@ public interface RedissonClient { *

* To increase reliability during failover, all operations wait for propagation to all Redis slaves. * - * @param name - name of object + * @param name name of object * @return Lock object */ RLock getLock(String name); + /** + * Returns Lock instance with specified options. + *

+ * Implements a non-fair locking so doesn't guarantees an acquire order by threads. + *

+ * To increase reliability during failover, all operations wait for propagation to all Redis slaves. + * + * @param options instance options + * @return Lock object + */ + RLock getLock(CommonOptions options); + /** * Returns Spin lock instance by name. *

@@ -509,7 +736,7 @@ public interface RedissonClient { *

* Lock doesn't use a pub/sub mechanism * - * @param name - name of object + * @param name name of object * @return Lock object */ RLock getSpinLock(String name); @@ -521,17 +748,35 @@ public interface RedissonClient { *

* Lock doesn't use a pub/sub mechanism * - * @param name - name of object + * @param name name of object * @return Lock object */ RLock getSpinLock(String name, LockOptions.BackOff backOff); + /** + * Returns Fenced Lock instance by name. + *

+ * Implements a non-fair locking so doesn't guarantee an acquire order by threads. + * + * @param name name of object + * @return Lock object + */ RFencedLock getFencedLock(String name); + /** + * Returns Fenced Lock instance with specified options.. + *

+ * Implements a non-fair locking so doesn't guarantee an acquire order by threads. + * + * @param options instance options + * @return Lock object + */ + RFencedLock getFencedLock(CommonOptions options); + /** * Returns MultiLock instance associated with specified locks * - * @param locks - collection of locks + * @param locks collection of locks * @return MultiLock object */ RLock getMultiLock(RLock... locks); @@ -549,26 +794,48 @@ public interface RedissonClient { *

* To increase reliability during failover, all operations wait for propagation to all Redis slaves. * - * @param name - name of object + * @param name name of object * @return Lock object */ RLock getFairLock(String name); + + /** + * Returns Lock instance with specified options. + *

+ * Implements a fair locking so it guarantees an acquire order by threads. + *

+ * To increase reliability during failover, all operations wait for propagation to all Redis slaves. + * + * @param options instance options + * @return Lock object + */ + RLock getFairLock(CommonOptions options); /** * Returns ReadWriteLock instance by name. *

* To increase reliability during failover, all operations wait for propagation to all Redis slaves. * - * @param name - name of object + * @param name name of object * @return Lock object */ RReadWriteLock getReadWriteLock(String name); + /** + * Returns ReadWriteLock instance with specified options. + *

+ * To increase reliability during failover, all operations wait for propagation to all Redis slaves. + * + * @param options instance options + * @return Lock object + */ + RReadWriteLock getReadWriteLock(CommonOptions options); + /** * Returns set instance by name. * * @param type of value - * @param name - name of object + * @param name name of object * @return Set object */ RSet getSet(String name); @@ -578,18 +845,27 @@ public interface RedissonClient { * using provided codec for set objects. * * @param type of value - * @param name - name of object - * @param codec - codec for values + * @param name name of object + * @param codec codec for values * @return Set object */ RSet getSet(String name, Codec codec); + /** + * Returns set instance with specified options. + * + * @param type of value + * @param options instance options + * @return Set object + */ + RSet getSet(PlainOptions options); + /** * Returns sorted set instance by name. * This sorted set uses comparator to sort objects. * * @param type of value - * @param name - name of object + * @param name name of object * @return SortedSet object */ RSortedSet getSortedSet(String name); @@ -600,18 +876,28 @@ public interface RedissonClient { * This sorted set sorts objects using comparator. * * @param type of value - * @param name - name of object - * @param codec - codec for values + * @param name name of object + * @param codec codec for values * @return SortedSet object */ RSortedSet getSortedSet(String name, Codec codec); + /** + * Returns sorted set instance with specified options. + * This sorted set uses comparator to sort objects. + * + * @param type of value + * @param options instance options + * @return SortedSet object + */ + RSortedSet getSortedSet(PlainOptions options); + /** * Returns Redis Sorted Set instance by name. * This sorted set sorts objects by object score. * * @param type of value - * @param name - name of object + * @param name name of object * @return ScoredSortedSet object */ RScoredSortedSet getScoredSortedSet(String name); @@ -622,29 +908,49 @@ public interface RedissonClient { * This sorted set sorts objects by object score. * * @param type of value - * @param name - name of object - * @param codec - codec for values + * @param name name of object + * @param codec codec for values * @return ScoredSortedSet object */ RScoredSortedSet getScoredSortedSet(String name, Codec codec); /** - * Returns String based Redis Sorted Set instance by name + * Returns Redis Sorted Set instance with specified options. + * This sorted set sorts objects by object score. + * + * @param type of value + * @param options instance options + * @return ScoredSortedSet object + */ + RScoredSortedSet getScoredSortedSet(PlainOptions options); + + /** + * Returns String based Redis Sorted Set instance by name. * All elements are inserted with the same score during addition, * in order to force lexicographical ordering * - * @param name - name of object + * @param name name of object * @return LexSortedSet object */ RLexSortedSet getLexSortedSet(String name); + /** + * Returns String based Redis Sorted Set instance with specified options. + * All elements are inserted with the same score during addition, + * in order to force lexicographical ordering + * + * @param options instance options + * @return LexSortedSet object + */ + RLexSortedSet getLexSortedSet(CommonOptions options); + /** * Returns Sharded Topic instance by name. *

* Messages are delivered to message listeners connected to the same Topic. *

* - * @param name - name of object + * @param name name of object * @return Topic object */ RShardedTopic getShardedTopic(String name); @@ -655,19 +961,30 @@ public interface RedissonClient { * Messages are delivered to message listeners connected to the same Topic. *

* - * @param name - name of object - * @param codec - codec for message + * @param name name of object + * @param codec codec for message * @return Topic object */ RShardedTopic getShardedTopic(String name, Codec codec); + /** + * Returns Sharded Topic instance with specified options. + *

+ * Messages are delivered to message listeners connected to the same Topic. + *

+ * + * @param options instance options + * @return Topic object + */ + RShardedTopic getShardedTopic(PlainOptions options); + /** * Returns topic instance by name. *

* Messages are delivered to message listeners connected to the same Topic. *

* - * @param name - name of object + * @param name name of object * @return Topic object */ RTopic getTopic(String name); @@ -679,12 +996,23 @@ public interface RedissonClient { * Messages are delivered to message listeners connected to the same Topic. *

* - * @param name - name of object - * @param codec - codec for message + * @param name name of object + * @param codec codec for message * @return Topic object */ RTopic getTopic(String name, Codec codec); + /** + * Returns topic instance with specified options. + *

+ * Messages are delivered to message listeners connected to the same Topic. + *

+ * + * @param options instance options + * @return Topic object + */ + RTopic getTopic(PlainOptions options); + /** * Returns reliable topic instance by name. *

@@ -693,7 +1021,7 @@ public interface RedissonClient { *

* Requires Redis 5.0.0 and higher. * - * @param name - name of object + * @param name name of object * @return ReliableTopic object */ RReliableTopic getReliableTopic(String name); @@ -707,12 +1035,25 @@ public interface RedissonClient { *

* Requires Redis 5.0.0 and higher. * - * @param name - name of object - * @param codec - codec for message + * @param name name of object + * @param codec codec for message * @return ReliableTopic object */ RReliableTopic getReliableTopic(String name, Codec codec); + /** + * Returns reliable topic instance with specified options. + *

+ * Dedicated Redis connection is allocated per instance (subscriber) of this object. + * Messages are delivered to all listeners attached to the same Redis setup. + *

+ * Requires Redis 5.0.0 and higher. + * + * @param options instance options + * @return ReliableTopic object + */ + RReliableTopic getReliableTopic(PlainOptions options); + /** * Returns topic instance satisfies by pattern name. * @@ -736,11 +1077,24 @@ public interface RedissonClient { * h[ae]llo subscribes to hello and hallo, but not hillo * * @param pattern of the topic - * @param codec - codec for message + * @param codec codec for message * @return PatterTopic object */ RPatternTopic getPatternTopic(String pattern, Codec codec); + /** + * Returns topic instance satisfies pattern name and specified options.. + * + * Supported glob-style patterns: + * h?llo subscribes to hello, hallo and hxllo + * h*llo subscribes to hllo and heeeello + * h[ae]llo subscribes to hello and hallo, but not hillo + * + * @param options instance options + * @return PatterTopic object + */ + RPatternTopic getPatternTopic(PatternTopicOptions options); + /** * Returns unbounded queue instance by name. * @@ -754,7 +1108,7 @@ public interface RedissonClient { * Returns transfer queue instance by name. * * @param type of values - * @param name - name of object + * @param name name of object * @return TransferQueue object */ RTransferQueue getTransferQueue(String name); @@ -764,12 +1118,21 @@ public interface RedissonClient { * using provided codec for queue objects. * * @param type of values - * @param name - name of object - * @param codec - code for values + * @param name name of object + * @param codec code for values * @return TransferQueue object */ RTransferQueue getTransferQueue(String name, Codec codec); + /** + * Returns transfer queue instance with specified options. + * + * @param type of values + * @param options instance options + * @return TransferQueue object + */ + RTransferQueue getTransferQueue(PlainOptions options); + /** * Returns unbounded delayed queue instance by name. *

@@ -777,7 +1140,7 @@ public interface RedissonClient { * All elements are inserted with transfer delay to destination queue. * * @param type of value - * @param destinationQueue - destination queue + * @param destinationQueue destination queue * @return Delayed queue object */ RDelayedQueue getDelayedQueue(RQueue destinationQueue); @@ -787,17 +1150,26 @@ public interface RedissonClient { * using provided codec for queue objects. * * @param type of value - * @param name - name of object - * @param codec - codec for message + * @param name name of object + * @param codec codec for message * @return Queue object */ RQueue getQueue(String name, Codec codec); - + + /** + * Returns unbounded queue instance with specified options. + * + * @param type of value + * @param options instance options + * @return queue object + */ + RQueue getQueue(PlainOptions options); + /** * Returns RingBuffer based queue. * * @param value type - * @param name - name of object + * @param name name of object * @return RingBuffer object */ RRingBuffer getRingBuffer(String name); @@ -806,12 +1178,21 @@ public interface RedissonClient { * Returns RingBuffer based queue. * * @param value type - * @param name - name of object - * @param codec - codec for values + * @param name name of object + * @param codec codec for values * @return RingBuffer object */ RRingBuffer getRingBuffer(String name, Codec codec); + /** + * Returns RingBuffer based queue instance with specified options. + * + * @param value type + * @param options instance options + * @return RingBuffer object + */ + RRingBuffer getRingBuffer(PlainOptions options); + /** * Returns priority unbounded queue instance by name. * It uses comparator to sort objects. @@ -828,12 +1209,14 @@ public interface RedissonClient { * It uses comparator to sort objects. * * @param type of value - * @param name - name of object - * @param codec - codec for message + * @param name name of object + * @param codec codec for message * @return Queue object */ RPriorityQueue getPriorityQueue(String name, Codec codec); + RPriorityQueue getPriorityQueue(PlainOptions options); + /** * Returns unbounded priority blocking queue instance by name. * It uses comparator to sort objects. @@ -850,12 +1233,22 @@ public interface RedissonClient { * It uses comparator to sort objects. * * @param type of value - * @param name - name of object - * @param codec - codec for message + * @param name name of object + * @param codec codec for message * @return Queue object */ RPriorityBlockingQueue getPriorityBlockingQueue(String name, Codec codec); + /** + * Returns unbounded priority blocking queue instance with specified options. + * It uses comparator to sort objects. + * + * @param type of value + * @param options instance options + * @return Queue object + */ + RPriorityBlockingQueue getPriorityBlockingQueue(PlainOptions options); + /** * Returns unbounded priority blocking deque instance by name. * It uses comparator to sort objects. @@ -872,11 +1265,21 @@ public interface RedissonClient { * It uses comparator to sort objects. * * @param type of value - * @param name - name of object - * @param codec - codec for message + * @param name name of object + * @param codec codec for message * @return Queue object */ RPriorityBlockingDeque getPriorityBlockingDeque(String name, Codec codec); + + /** + * Returns unbounded priority blocking deque instance with specified options. + * It uses comparator to sort objects. + * + * @param type of value + * @param options instance options + * @return Queue object + */ + RPriorityBlockingDeque getPriorityBlockingDeque(PlainOptions options); /** * Returns priority unbounded deque instance by name. @@ -894,17 +1297,27 @@ public interface RedissonClient { * It uses comparator to sort objects. * * @param type of value - * @param name - name of object - * @param codec - codec for message + * @param name name of object + * @param codec codec for message * @return Queue object */ RPriorityDeque getPriorityDeque(String name, Codec codec); + + /** + * Returns priority unbounded deque instance with specified options. + * It uses comparator to sort objects. + * + * @param type of value + * @param options instance options + * @return Queue object + */ + RPriorityDeque getPriorityDeque(PlainOptions options); /** * Returns unbounded blocking queue instance by name. * * @param type of value - * @param name - name of object + * @param name name of object * @return BlockingQueue object */ RBlockingQueue getBlockingQueue(String name); @@ -914,12 +1327,21 @@ public interface RedissonClient { * using provided codec for queue objects. * * @param type of value - * @param name - name of queue - * @param codec - queue objects codec + * @param name name of queue + * @param codec queue objects codec * @return BlockingQueue object */ RBlockingQueue getBlockingQueue(String name, Codec codec); + /** + * Returns unbounded blocking queue instance with specified options. + * + * @param type of value + * @param options instance options + * @return BlockingQueue object + */ + RBlockingQueue getBlockingQueue(PlainOptions options); + /** * Returns bounded blocking queue instance by name. * @@ -934,17 +1356,26 @@ public interface RedissonClient { * using provided codec for queue objects. * * @param type of value - * @param name - name of queue - * @param codec - codec for values + * @param name name of queue + * @param codec codec for values * @return BoundedBlockingQueue object */ RBoundedBlockingQueue getBoundedBlockingQueue(String name, Codec codec); + /** + * Returns bounded blocking queue instance with specified options. + * + * @param type of value + * @param options instance options + * @return BoundedBlockingQueue object + */ + RBoundedBlockingQueue getBoundedBlockingQueue(PlainOptions options); + /** * Returns unbounded deque instance by name. - * + * * @param type of value - * @param name - name of object + * @param name name of object * @return Deque object */ RDeque getDeque(String name); @@ -954,17 +1385,26 @@ public interface RedissonClient { * using provided codec for deque objects. * * @param type of value - * @param name - name of object - * @param codec - codec for values + * @param name name of object + * @param codec codec for values * @return Deque object */ RDeque getDeque(String name, Codec codec); + /** + * Returns unbounded deque instance with specified options. + * + * @param type of value + * @param options instance options + * @return Deque object + */ + RDeque getDeque(PlainOptions options); + /** * Returns unbounded blocking deque instance by name. - * + * * @param type of value - * @param name - name of object + * @param name name of object * @return BlockingDeque object */ RBlockingDeque getBlockingDeque(String name); @@ -974,65 +1414,122 @@ public interface RedissonClient { * using provided codec for deque objects. * * @param type of value - * @param name - name of object - * @param codec - deque objects codec + * @param name name of object + * @param codec deque objects codec * @return BlockingDeque object */ RBlockingDeque getBlockingDeque(String name, Codec codec); + /** + * Returns unbounded blocking deque instance with specified options. + * + * @param type of value + * @param options instance options + * @return BlockingDeque object + */ + RBlockingDeque getBlockingDeque(PlainOptions options); + /** * Returns atomicLong instance by name. * - * @param name - name of object + * @param name name of object * @return AtomicLong object */ RAtomicLong getAtomicLong(String name); + /** + * Returns atomicLong instance with specified options. + * + * @param options instance options + * @return AtomicLong object + */ + RAtomicLong getAtomicLong(CommonOptions options); + /** * Returns atomicDouble instance by name. * - * @param name - name of object + * @param name name of object * @return AtomicDouble object */ RAtomicDouble getAtomicDouble(String name); + /** + * Returns atomicDouble instance with specified options. + * + * @param options instance options + * @return AtomicDouble object + */ + RAtomicDouble getAtomicDouble(CommonOptions options); + /** * Returns LongAdder instances by name. * - * @param name - name of object + * @param name name of object * @return LongAdder object */ RLongAdder getLongAdder(String name); + /** + * Returns LongAdder instances with specified options. + * + * @param options instance options + * @return LongAdder object + */ + RLongAdder getLongAdder(CommonOptions options); + /** * Returns DoubleAdder instances by name. * - * @param name - name of object + * @param name name of object * @return LongAdder object */ RDoubleAdder getDoubleAdder(String name); - + + /** + * Returns DoubleAdder instances with specified options. + * + * @param options instance options + * @return LongAdder object + */ + RDoubleAdder getDoubleAdder(CommonOptions options); + /** * Returns countDownLatch instance by name. * - * @param name - name of object + * @param name name of object * @return CountDownLatch object */ RCountDownLatch getCountDownLatch(String name); + /** + * Returns countDownLatch instance with specified options. + * + * @param options instance options + * @return CountDownLatch object + */ + RCountDownLatch getCountDownLatch(CommonOptions options); + /** * Returns bitSet instance by name. * - * @param name - name of object + * @param name name of object * @return BitSet object */ RBitSet getBitSet(String name); + /** + * Returns bitSet instance with specified options. + * + * @param options instance options + * @return BitSet object + */ + RBitSet getBitSet(CommonOptions options); + /** * Returns bloom filter instance by name. * * @param type of value - * @param name - name of object + * @param name name of object * @return BloomFilter object */ RBloomFilter getBloomFilter(String name); @@ -1042,35 +1539,60 @@ public interface RedissonClient { * using provided codec for objects. * * @param type of value - * @param name - name of object - * @param codec - codec for values + * @param name name of object + * @param codec codec for values * @return BloomFilter object */ RBloomFilter getBloomFilter(String name, Codec codec); /** - * Returns id generator by name. + * Returns bloom filter instance with specified options. * - * @param name - name of object + * @param type of value + * @param options instance options + * @return BloomFilter object + */ + RBloomFilter getBloomFilter(PlainOptions options); + + /** + * Returns id generator instance by name. + * + * @param name name of object * @return IdGenerator object */ RIdGenerator getIdGenerator(String name); /** - * Returns interface for Redis Function feature + * Returns id generator instance with specified options. + * + * @param options instance options + * @return IdGenerator object + */ + RIdGenerator getIdGenerator(CommonOptions options); + + /** + * Returns API for Redis Function feature * * @return function object */ RFunction getFunction(); /** - * Returns interface for Redis Function feature using provided codec + * Returns API for Redis Function feature using provided codec * - * @param codec - codec for params and result + * @param codec codec for params and result * @return function interface */ RFunction getFunction(Codec codec); + /** + * Returns interface for Redis Function feature with specified options. + * + * @param options instance options + * @return function object + */ + RFunction getFunction(OptionalOptions options); + /** * Returns script operations object * @@ -1081,70 +1603,96 @@ public interface RedissonClient { /** * Returns script operations object using provided codec. * - * @param codec - codec for params and result + * @param codec codec for params and result * @return Script object */ RScript getScript(Codec codec); + /** + * Returns script operations object with specified options. + * + * @param options instance options + * @return Script object + */ + RScript getScript(OptionalOptions options); + /** * Returns ScheduledExecutorService by name * - * @param name - name of object + * @param name name of object * @return ScheduledExecutorService object */ RScheduledExecutorService getExecutorService(String name); /** - * Returns ScheduledExecutorService by name + * Use {@link #getExecutorService(org.redisson.api.options.ExecutorOptions)} instead * - * @param name - name of object - * @param options - options for executor + * @param name name of object + * @param options options for executor * @return ScheduledExecutorService object */ + @Deprecated RScheduledExecutorService getExecutorService(String name, ExecutorOptions options); /** * Returns ScheduledExecutorService by name * using provided codec for task, response and request serialization * - * @param name - name of object - * @param codec - codec for task, response and request + * @param name name of object + * @param codec codec for task, response and request * @return ScheduledExecutorService object * @since 2.8.2 */ RScheduledExecutorService getExecutorService(String name, Codec codec); /** - * Returns ScheduledExecutorService by name - * using provided codec for task, response and request serialization - * - * @param name - name of object - * @param codec - codec for task, response and request - * @param options - options for executor + * Use {@link #getExecutorService(org.redisson.api.options.ExecutorOptions)} instead + * + * @param name name of object + * @param codec codec for task, response and request + * @param options options for executor * @return ScheduledExecutorService object */ + @Deprecated RScheduledExecutorService getExecutorService(String name, Codec codec, ExecutorOptions options); + + /** + * Returns ScheduledExecutorService with defined options + *

+ * Usage examples: + *

+     * RScheduledExecutorService service = redisson.getExecutorService(
+     *                                                  ExecutorOptions.name("test")
+     *                                                  .taskRetryInterval(Duration.ofSeconds(60)));
+     * 
+ * + * @param options options instance + * @return ScheduledExecutorService object + */ + RScheduledExecutorService getExecutorService(org.redisson.api.options.ExecutorOptions options); /** * Returns object for remote operations prefixed with the default name (redisson_remote_service) * * @return RemoteService object */ + @Deprecated RRemoteService getRemoteService(); /** * Returns object for remote operations prefixed with the default name (redisson_remote_service) * and uses provided codec for method arguments and result. * - * @param codec - codec for response and request + * @param codec codec for response and request * @return RemoteService object */ + @Deprecated RRemoteService getRemoteService(Codec codec); /** * Returns object for remote operations prefixed with the specified name * - * @param name - the name used as the Redis key prefix for the services + * @param name the name used as the Redis key prefix for the services * @return RemoteService object */ RRemoteService getRemoteService(String name); @@ -1153,16 +1701,24 @@ public interface RedissonClient { * Returns object for remote operations prefixed with the specified name * and uses provided codec for method arguments and result. * - * @param name - the name used as the Redis key prefix for the services - * @param codec - codec for response and request + * @param name the name used as the Redis key prefix for the services + * @param codec codec for response and request * @return RemoteService object */ RRemoteService getRemoteService(String name, Codec codec); + /** + * Returns object for remote operations prefixed with specified options. + * + * @param options instance options + * @return RemoteService object + */ + RRemoteService getRemoteService(PlainOptions options); + /** * Creates transaction with READ_COMMITTED isolation level. * - * @param options - transaction configuration + * @param options transaction configuration * @return Transaction object */ RTransaction createTransaction(TransactionOptions options); @@ -1173,7 +1729,7 @@ public interface RedissonClient { *

* See http://redis.io/topics/pipelining * - * @param options - batch configuration + * @param options batch configuration * @return Batch object */ RBatch createBatch(BatchOptions options); @@ -1197,13 +1753,28 @@ public interface RedissonClient { RKeys getKeys(); /** - * Returns RedissonAttachedLiveObjectService which can be used to - * retrieve live REntity(s) + * Returns interface for operations over Redis keys with specified options. + * Each of Redis/Redisson object is associated with own key. + * + * @return Keys object + */ + RKeys getKeys(KeysOptions options); + + /** + * Returns Live Object Service which is used to store Java objects * * @return LiveObjectService object */ RLiveObjectService getLiveObjectService(); + /** + * Returns Live Object Service which is used to store Java objects + * with specified options. + * + * @return LiveObjectService object + */ + RLiveObjectService getLiveObjectService(LiveObjectOptions options); + /** * Returns RxJava Redisson instance * diff --git a/redisson/src/main/java/org/redisson/api/RedissonReactiveClient.java b/redisson/src/main/java/org/redisson/api/RedissonReactiveClient.java index 5aaf161f0..4218b7b78 100644 --- a/redisson/src/main/java/org/redisson/api/RedissonReactiveClient.java +++ b/redisson/src/main/java/org/redisson/api/RedissonReactiveClient.java @@ -15,6 +15,7 @@ */ package org.redisson.api; +import org.redisson.api.options.*; import org.redisson.client.codec.Codec; import org.redisson.codec.JsonCodec; import org.redisson.config.Config; @@ -38,7 +39,7 @@ public interface RedissonReactiveClient { * * @param value type * @param label type - * @param name - name of instance + * @param name name of instance * @return RTimeSeries object */ RTimeSeriesReactive getTimeSeries(String name); @@ -49,12 +50,22 @@ public interface RedissonReactiveClient { * * @param value type * @param label type - * @param name - name of instance - * @param codec - codec for values + * @param name name of instance + * @param codec codec for values * @return RTimeSeries object */ RTimeSeriesReactive getTimeSeries(String name, Codec codec); + /** + * Returns time-series instance with specified options. + * + * @param value type + * @param label type + * @param options instance options + * @return RTimeSeries object + */ + RTimeSeriesReactive getTimeSeries(PlainOptions options); + /** * Returns stream instance by name *

@@ -75,12 +86,24 @@ public interface RedissonReactiveClient { * * @param type of key * @param type of value - * @param name - name of stream - * @param codec - codec for entry + * @param name name of stream + * @param codec codec for entry * @return RStream object */ RStreamReactive getStream(String name, Codec codec); + /** + * Returns time-series instance with specified options. + *

+ * Requires Redis 5.0.0 and higher. + * + * @param type of key + * @param type of value + * @param options instance options + * @return RStream object + */ + RStreamReactive getStream(PlainOptions options); + /** * Returns API for RediSearch module * @@ -95,11 +118,19 @@ public interface RedissonReactiveClient { */ RSearchReactive getSearch(Codec codec); + /** + * Returns API for RediSearch module with specified options. + * + * @param options instance options + * @return RSearch object + */ + RSearchReactive getSearch(OptionalOptions options); + /** * Returns geospatial items holder instance by name. * * @param type of value - * @param name - name of object + * @param name name of object * @return Geo object */ RGeoReactive getGeo(String name); @@ -109,12 +140,21 @@ public interface RedissonReactiveClient { * using provided codec for geospatial members. * * @param type of value - * @param name - name of object - * @param codec - codec for value + * @param name name of object + * @param codec codec for value * @return Geo object */ RGeoReactive getGeo(String name, Codec codec); - + + /** + * Returns geospatial items holder instance with specified options. + * + * @param type of value + * @param options instance options + * @return Geo object + */ + RGeoReactive getGeo(PlainOptions options); + /** * Returns rate limiter instance by name * @@ -123,6 +163,14 @@ public interface RedissonReactiveClient { */ RRateLimiterReactive getRateLimiter(String name); + /** + * Returns rate limiter instance with specified options. + * + * @param options instance options + * @return RateLimiter object + */ + RRateLimiterReactive getRateLimiter(CommonOptions options); + /** * Returns binary stream holder instance by name * @@ -131,33 +179,68 @@ public interface RedissonReactiveClient { */ RBinaryStreamReactive getBinaryStream(String name); + /** + * Returns binary stream holder instance with specified options. + * + * @param options instance options + * @return BinaryStream object + */ + RBinaryStreamReactive getBinaryStream(CommonOptions options); + /** * Returns semaphore instance by name * - * @param name - name of object + * @param name name of object * @return Semaphore object */ RSemaphoreReactive getSemaphore(String name); - + + /** + * Returns semaphore instance with specified options. + * + * @param options instance options + * @return Semaphore object + */ + RSemaphoreReactive getSemaphore(CommonOptions options); + /** * Returns semaphore instance by name. * Supports lease time parameter for each acquired permit. * - * @param name - name of object + * @param name name of object * @return PermitExpirableSemaphore object */ RPermitExpirableSemaphoreReactive getPermitExpirableSemaphore(String name); - + + /** + * Returns semaphore instance with specified options. + * Supports lease time parameter for each acquired permit. + * + * @param options instance options + * @return PermitExpirableSemaphore object + */ + RPermitExpirableSemaphoreReactive getPermitExpirableSemaphore(CommonOptions options); + /** * Returns ReadWriteLock instance by name. *

* To increase reliability during failover, all operations wait for propagation to all Redis slaves. * - * @param name - name of object + * @param name name of object * @return Lock object */ RReadWriteLockReactive getReadWriteLock(String name); - + + /** + * Returns ReadWriteLock instance with specified options. + *

+ * To increase reliability during failover, all operations wait for propagation to all Redis slaves. + * + * @param options instance options + * @return Lock object + */ + RReadWriteLockReactive getReadWriteLock(CommonOptions options); + /** * Returns Lock instance by name. *

@@ -165,11 +248,23 @@ public interface RedissonReactiveClient { *

* To increase reliability during failover, all operations wait for propagation to all Redis slaves. * - * @param name - name of object + * @param name name of object * @return Lock object */ RLockReactive getFairLock(String name); - + + /** + * Returns Lock instance with specified options. + *

+ * Implements a fair locking so it guarantees an acquire order by threads. + *

+ * To increase reliability during failover, all operations wait for propagation to all Redis slaves. + * + * @param options instance options + * @return Lock object + */ + RLockReactive getFairLock(CommonOptions options); + /** * Returns Lock instance by name. *

@@ -177,11 +272,23 @@ public interface RedissonReactiveClient { *

* To increase reliability during failover, all operations wait for propagation to all Redis slaves. * - * @param name - name of object + * @param name name of object * @return Lock object */ RLockReactive getLock(String name); + /** + * Returns Lock instance with specified options. + *

+ * Implements a non-fair locking so doesn't guarantees an acquire order by threads. + *

+ * To increase reliability during failover, all operations wait for propagation to all Redis slaves. + * + * @param options instance options + * @return Lock object + */ + RLockReactive getLock(CommonOptions options); + /** * Returns Spin lock instance by name. *

@@ -189,7 +296,7 @@ public interface RedissonReactiveClient { *

* Lock doesn't use a pub/sub mechanism * - * @param name - name of object + * @param name name of object * @return Lock object */ RLockReactive getSpinLock(String name); @@ -201,7 +308,7 @@ public interface RedissonReactiveClient { *

* Lock doesn't use a pub/sub mechanism * - * @param name - name of object + * @param name name of object * @return Lock object */ RLockReactive getSpinLock(String name, LockOptions.BackOff backOff); @@ -216,10 +323,20 @@ public interface RedissonReactiveClient { */ RFencedLockReactive getFencedLock(String name); + /** + * Returns Fenced Lock instance with specified options.. + *

+ * Implements a non-fair locking so doesn't guarantee an acquire order by threads. + * + * @param options instance options + * @return Lock object + */ + RFencedLockReactive getFencedLock(CommonOptions options); + /** * Returns MultiLock instance associated with specified locks * - * @param locks - collection of locks + * @param locks collection of locks * @return MultiLock object */ RLockReactive getMultiLock(RLockReactive... locks); @@ -239,11 +356,19 @@ public interface RedissonReactiveClient { /** * Returns CountDownLatch instance by name. * - * @param name - name of object + * @param name name of object * @return CountDownLatch object */ RCountDownLatchReactive getCountDownLatch(String name); + /** + * Returns countDownLatch instance with specified options. + * + * @param options instance options + * @return CountDownLatch object + */ + RCountDownLatchReactive getCountDownLatch(CommonOptions options); + /** * Returns set-based cache instance by name. * Supports value eviction with a given TTL value. @@ -251,7 +376,7 @@ public interface RedissonReactiveClient { *

If eviction is not required then it's better to use regular map {@link #getSet(String, Codec)}.

* * @param type of values - * @param name - name of object + * @param name name of object * @return SetCache object */ RSetCacheReactive getSetCache(String name); @@ -263,12 +388,24 @@ public interface RedissonReactiveClient { *

If eviction is not required then it's better to use regular map {@link #getSet(String, Codec)}.

* * @param type of values - * @param name - name of object - * @param codec - codec for values + * @param name name of object + * @param codec codec for values * @return SetCache object */ RSetCacheReactive getSetCache(String name, Codec codec); + /** + * Returns set-based cache instance with specified options. + * Supports value eviction with a given TTL value. + * + *

If eviction is not required then it's better to use regular map {@link #getSet(PlainOptions)}.

+ * + * @param type of value + * @param options instance options + * @return SetCache object + */ + RSetCacheReactive getSetCache(PlainOptions options); + /** * Returns map-based cache instance by name * using provided codec for both cache keys and values. @@ -278,8 +415,8 @@ public interface RedissonReactiveClient { * * @param type of keys * @param type of values - * @param name - name of object - * @param codec - codec for values + * @param name name of object + * @param codec codec for values * @return MapCache object */ RMapCacheReactive getMapCache(String name, Codec codec); @@ -293,11 +430,12 @@ public interface RedissonReactiveClient { * * @param type of key * @param type of value - * @param name - object name - * @param codec - codec for keys and values - * @param options - map options + * @param name object name + * @param codec codec for keys and values + * @param options map options * @return MapCache object */ + @Deprecated RMapCacheReactive getMapCache(String name, Codec codec, MapCacheOptions options); /** @@ -308,7 +446,7 @@ public interface RedissonReactiveClient { * * @param type of keys * @param type of values - * @param name - name of object + * @param name name of object * @return MapCache object */ RMapCacheReactive getMapCache(String name); @@ -321,17 +459,31 @@ public interface RedissonReactiveClient { * * @param type of key * @param type of value - * @param name - name of object - * @param options - map options + * @param name name of object + * @param options map options * @return MapCache object */ + @Deprecated RMapCacheReactive getMapCache(String name, MapCacheOptions options); - + + /** + * Returns map-based cache instance with specified options. + * Supports entry eviction with a given MaxIdleTime and TTL settings. + *

+ * If eviction is not required then it's better to use regular map {@link #getMap(org.redisson.api.options.MapOptions)}.

+ * + * @param type of key + * @param type of value + * @param options instance options + * @return MapCache object + */ + RMapCacheReactive getMapCache(org.redisson.api.options.MapCacheOptions options); + /** * Returns object holder instance by name * * @param type of value - * @param name - name of object + * @param name name of object * @return Bucket object */ RBucketReactive getBucket(String name); @@ -341,12 +493,21 @@ public interface RedissonReactiveClient { * using provided codec for object. * * @param type of value - * @param name - name of object - * @param codec - codec for value + * @param name name of object + * @param codec codec for value * @return Bucket object */ RBucketReactive getBucket(String name, Codec codec); + /** + * Returns object holder instance with specified options. + * + * @param type of value + * @param options instance options + * @return Bucket object + */ + RBucketReactive getBucket(PlainOptions options); + /** * Returns interface for mass operations with Bucket objects. * @@ -358,18 +519,27 @@ public interface RedissonReactiveClient { * Returns interface for mass operations with Bucket objects * using provided codec for object. * - * @param codec - codec for bucket objects + * @param codec codec for bucket objects * @return Buckets */ RBucketsReactive getBuckets(Codec codec); /** - * Returns a list of object holder instances by a key pattern + * Returns API for mass operations over Bucket objects with specified options. + * + * @param options instance options + * @return Buckets object + */ + RBucketsReactive getBuckets(OptionalOptions options); + + /** + * Use {@link #getBuckets()} instead. * * @param type of value - * @param pattern - pattern for name of buckets + * @param pattern pattern for name of buckets * @return list of buckets */ + @Deprecated List> findBuckets(String pattern); /** @@ -382,11 +552,20 @@ public interface RedissonReactiveClient { */ RJsonBucketReactive getJsonBucket(String name, JsonCodec codec); + /** + * Returns JSON data holder instance with specified options. + * + * @param type of value + * @param options instance options + * @return JsonBucket object + */ + RJsonBucketReactive getJsonBucket(JsonBucketOptions options); + /** * Returns HyperLogLog instance by name. * * @param type of values - * @param name - name of object + * @param name name of object * @return HyperLogLog object */ RHyperLogLogReactive getHyperLogLog(String name); @@ -396,25 +575,42 @@ public interface RedissonReactiveClient { * using provided codec for hll objects. * * @param type of values - * @param name - name of object - * @param codec - codec of values + * @param name name of object + * @param codec codec of values * @return HyperLogLog object */ RHyperLogLogReactive getHyperLogLog(String name, Codec codec); + /** + * Returns HyperLogLog instance with specified options. + * + * @param type of value + * @param options instance options + * @return HyperLogLog object + */ + RHyperLogLogReactive getHyperLogLog(PlainOptions options); + /** * Returns id generator by name. * - * @param name - name of object + * @param name name of object * @return IdGenerator object */ RIdGeneratorReactive getIdGenerator(String name); + /** + * Returns id generator instance with specified options. + * + * @param options instance options + * @return IdGenerator object + */ + RIdGeneratorReactive getIdGenerator(CommonOptions options); + /** * Returns list instance by name. * * @param type of values - * @param name - name of object + * @param name name of object * @return List object */ RListReactive getList(String name); @@ -424,18 +620,27 @@ public interface RedissonReactiveClient { * using provided codec for list objects. * * @param type of values - * @param name - name of object - * @param codec - codec for values + * @param name name of object + * @param codec codec for values * @return List object */ RListReactive getList(String name, Codec codec); + /** + * Returns list instance with specified options. + * + * @param type of value + * @param options instance options + * @return List object + */ + RListReactive getList(PlainOptions options); + /** * Returns List based Multimap instance by name. * * @param type of key * @param type of value - * @param name - name of object + * @param name name of object * @return ListMultimap object */ RListMultimapReactive getListMultimap(String name); @@ -446,12 +651,22 @@ public interface RedissonReactiveClient { * * @param type of key * @param type of value - * @param name - name of object - * @param codec - codec for keys and values + * @param name name of object + * @param codec codec for keys and values * @return RListMultimapReactive object */ RListMultimapReactive getListMultimap(String name, Codec codec); + /** + * Returns List based Multimap instance with specified options. + * + * @param type of key + * @param type of value + * @param options instance options + * @return ListMultimap object + */ + RListMultimapReactive getListMultimap(PlainOptions options); + /** * Returns List based Multimap cache instance by name. * Supports key eviction by specifying a time to live. @@ -459,7 +674,7 @@ public interface RedissonReactiveClient { * * @param type of key * @param type of value - * @param name - name of object + * @param name name of object * @return RListMultimapCacheReactive object */ RListMultimapCacheReactive getListMultimapCache(String name); @@ -471,18 +686,31 @@ public interface RedissonReactiveClient { * * @param type of key * @param type of value - * @param name - name of object - * @param codec - codec for keys and values + * @param name name of object + * @param codec codec for keys and values * @return RListMultimapCacheReactive object */ RListMultimapCacheReactive getListMultimapCache(String name, Codec codec); + /** + * Returns List based Multimap instance by name. + * Supports key-entry eviction with a given TTL value. + * + *

If eviction is not required then it's better to use regular map {@link #getSetMultimap(String)}.

+ * + * @param type of key + * @param type of value + * @param options instance options + * @return ListMultimapCache object + */ + RListMultimapCacheReactive getListMultimapCache(PlainOptions options); + /** * Returns Set based Multimap instance by name. * * @param type of key * @param type of value - * @param name - name of object + * @param name name of object * @return SetMultimap object */ RSetMultimapReactive getSetMultimap(String name); @@ -493,12 +721,22 @@ public interface RedissonReactiveClient { * * @param type of key * @param type of value - * @param name - name of object - * @param codec - codec for keys and values + * @param name name of object + * @param codec codec for keys and values * @return SetMultimap object */ RSetMultimapReactive getSetMultimap(String name, Codec codec); + /** + * Returns Set based Multimap instance with specified options. + * + * @param type of key + * @param type of value + * @param options instance options + * @return SetMultimap object + */ + RSetMultimapReactive getSetMultimap(PlainOptions options); + /** * Returns Set based Multimap cache instance by name. * Supports key eviction by specifying a time to live. @@ -506,7 +744,7 @@ public interface RedissonReactiveClient { * * @param type of key * @param type of value - * @param name - name of object + * @param name name of object * @return RSetMultimapCacheReactive object */ RSetMultimapCacheReactive getSetMultimapCache(String name); @@ -518,18 +756,31 @@ public interface RedissonReactiveClient { * * @param type of key * @param type of value - * @param name - name of object - * @param codec - codec for keys and values + * @param name name of object + * @param codec codec for keys and values * @return RSetMultimapCacheReactive object */ RSetMultimapCacheReactive getSetMultimapCache(String name, Codec codec); + /** + * Returns Set based Multimap instance with specified options. + * Supports key-entry eviction with a given TTL value. + * + *

If eviction is not required then it's better to use regular map {@link #getSetMultimap(PlainOptions)}.

+ * + * @param type of key + * @param type of value + * @param options instance options + * @return SetMultimapCache object + */ + RSetMultimapCacheReactive getSetMultimapCache(PlainOptions options); + /** * Returns map instance by name. * * @param type of keys * @param type of values - * @param name - name of object + * @param name name of object * @return Map object */ RMapReactive getMap(String name); @@ -539,10 +790,11 @@ public interface RedissonReactiveClient { * * @param type of key * @param type of value - * @param name - name of object - * @param options - map options + * @param name name of object + * @param options map options * @return Map object */ + @Deprecated RMapReactive getMap(String name, MapOptions options); /** @@ -551,8 +803,8 @@ public interface RedissonReactiveClient { * * @param type of keys * @param type of values - * @param name - name of object - * @param codec - codec for keys and values + * @param name name of object + * @param codec codec for keys and values * @return Map object */ RMapReactive getMap(String name, Codec codec); @@ -563,23 +815,35 @@ public interface RedissonReactiveClient { * * @param type of key * @param type of value - * @param name - name of object - * @param codec - codec for keys and values - * @param options - map options + * @param name name of object + * @param codec codec for keys and values + * @param options map options * @return Map object */ + @Deprecated RMapReactive getMap(String name, Codec codec, MapOptions options); + /** + * Returns map instance by name. + * + * @param type of key + * @param type of value + * @param options instance options + * @return Map object + */ + RMapReactive getMap(org.redisson.api.options.MapOptions options); + /** * Returns local cached map instance by name. * Configured by parameters of options-object. * * @param type of key * @param type of value - * @param name - name of object - * @param options - local map options + * @param name name of object + * @param options local map options * @return LocalCachedMap object */ + @Deprecated RLocalCachedMapReactive getLocalCachedMap(String name, LocalCachedMapOptions options); /** @@ -588,18 +852,29 @@ public interface RedissonReactiveClient { * * @param type of key * @param type of value - * @param name - name of object - * @param codec - codec for keys and values - * @param options - local map options + * @param name name of object + * @param codec codec for keys and values + * @param options local map options * @return LocalCachedMap object */ + @Deprecated RLocalCachedMapReactive getLocalCachedMap(String name, Codec codec, LocalCachedMapOptions options); + /** + * Returns local cached map instance with specified options. + * + * @param type of key + * @param type of value + * @param options instance options + * @return LocalCachedMap object + */ + RLocalCachedMapReactive getLocalCachedMap(org.redisson.api.options.LocalCachedMapOptions options); + /** * Returns set instance by name. * * @param type of values - * @param name - name of object + * @param name name of object * @return Set object */ RSetReactive getSet(String name); @@ -609,12 +884,21 @@ public interface RedissonReactiveClient { * using provided codec for set objects. * * @param type of values - * @param name - name of set - * @param codec - codec for values + * @param name name of set + * @param codec codec for values * @return Set object */ RSetReactive getSet(String name, Codec codec); + /** + * Returns set instance with specified options. + * + * @param type of value + * @param options instance options + * @return Set object + */ + RSetReactive getSet(PlainOptions options); + /** * Returns Redis Sorted Set instance by name. * This sorted set sorts objects by object score. @@ -631,29 +915,49 @@ public interface RedissonReactiveClient { * This sorted set sorts objects by object score. * * @param type of values - * @param name - name of scored sorted set - * @param codec - codec for values + * @param name name of scored sorted set + * @param codec codec for values * @return ScoredSortedSet object */ RScoredSortedSetReactive getScoredSortedSet(String name, Codec codec); + /** + * Returns Redis Sorted Set instance with specified options. + * This sorted set sorts objects by object score. + * + * @param type of value + * @param options instance options + * @return ScoredSortedSet object + */ + RScoredSortedSetReactive getScoredSortedSet(PlainOptions options); + /** * Returns String based Redis Sorted Set instance by name * All elements are inserted with the same score during addition, * in order to force lexicographical ordering * - * @param name - name of object + * @param name name of object * @return LexSortedSet object */ RLexSortedSetReactive getLexSortedSet(String name); + /** + * Returns String based Redis Sorted Set instance with specified options. + * All elements are inserted with the same score during addition, + * in order to force lexicographical ordering + * + * @param options instance options + * @return LexSortedSet object + */ + RLexSortedSetReactive getLexSortedSet(CommonOptions options); + /** * Returns Sharded Topic instance by name. *

* Messages are delivered to message listeners connected to the same Topic. *

* - * @param name - name of object + * @param name name of object * @return Topic object */ RShardedTopicReactive getShardedTopic(String name); @@ -664,16 +968,27 @@ public interface RedissonReactiveClient { * Messages are delivered to message listeners connected to the same Topic. *

* - * @param name - name of object - * @param codec - codec for message + * @param name name of object + * @param codec codec for message * @return Topic object */ RShardedTopicReactive getShardedTopic(String name, Codec codec); + /** + * Returns Sharded Topic instance with specified options. + *

+ * Messages are delivered to message listeners connected to the same Topic. + *

+ * + * @param options instance options + * @return Topic object + */ + RShardedTopicReactive getShardedTopic(PlainOptions options); + /** * Returns topic instance by name. * - * @param name - name of object + * @param name name of object * @return Topic object */ RTopicReactive getTopic(String name); @@ -682,12 +997,23 @@ public interface RedissonReactiveClient { * Returns topic instance by name * using provided codec for messages. * - * @param name - name of object - * @param codec - codec for message + * @param name name of object + * @param codec codec for message * @return Topic object */ RTopicReactive getTopic(String name, Codec codec); + /** + * Returns topic instance with specified options. + *

+ * Messages are delivered to message listeners connected to the same Topic. + *

+ * + * @param options instance options + * @return Topic object + */ + RTopicReactive getTopic(PlainOptions options); + /** * Returns reliable topic instance by name. *

@@ -696,7 +1022,7 @@ public interface RedissonReactiveClient { *

* Requires Redis 5.0.0 and higher. * - * @param name - name of object + * @param name name of object * @return ReliableTopic object */ RReliableTopicReactive getReliableTopic(String name); @@ -710,12 +1036,25 @@ public interface RedissonReactiveClient { *

* Requires Redis 5.0.0 and higher. * - * @param name - name of object - * @param codec - codec for message + * @param name name of object + * @param codec codec for message * @return ReliableTopic object */ RReliableTopicReactive getReliableTopic(String name, Codec codec); + /** + * Returns reliable topic instance with specified options. + *

+ * Dedicated Redis connection is allocated per instance (subscriber) of this object. + * Messages are delivered to all listeners attached to the same Redis setup. + *

+ * Requires Redis 5.0.0 and higher. + * + * @param options instance options + * @return ReliableTopic object + */ + RReliableTopicReactive getReliableTopic(PlainOptions options); + /** * Returns topic instance satisfies by pattern name. * @@ -739,16 +1078,29 @@ public interface RedissonReactiveClient { * h[ae]llo subscribes to hello and hallo, but not hillo * * @param pattern of the topic - * @param codec - codec for message + * @param codec codec for message * @return PatternTopic object */ RPatternTopicReactive getPatternTopic(String pattern, Codec codec); + /** + * Returns topic instance satisfies pattern name and specified options.. + * + * Supported glob-style patterns: + * h?llo subscribes to hello, hallo and hxllo + * h*llo subscribes to hllo and heeeello + * h[ae]llo subscribes to hello and hallo, but not hillo + * + * @param options instance options + * @return PatterTopic object + */ + RPatternTopicReactive getPatternTopic(PatternTopicOptions options); + /** * Returns queue instance by name. * * @param type of values - * @param name - name of object + * @param name name of object * @return Queue object */ RQueueReactive getQueue(String name); @@ -758,17 +1110,26 @@ public interface RedissonReactiveClient { * using provided codec for queue objects. * * @param type of values - * @param name - name of object - * @param codec - codec for values + * @param name name of object + * @param codec codec for values * @return Queue object */ RQueueReactive getQueue(String name, Codec codec); + /** + * Returns unbounded queue instance with specified options. + * + * @param type of value + * @param options instance options + * @return queue object + */ + RQueueReactive getQueue(PlainOptions options); + /** * Returns RingBuffer based queue. * * @param value type - * @param name - name of object + * @param name name of object * @return RingBuffer object */ RRingBufferReactive getRingBuffer(String name); @@ -777,17 +1138,26 @@ public interface RedissonReactiveClient { * Returns RingBuffer based queue. * * @param value type - * @param name - name of object - * @param codec - codec for values + * @param name name of object + * @param codec codec for values * @return RingBuffer object */ RRingBufferReactive getRingBuffer(String name, Codec codec); - + + /** + * Returns RingBuffer based queue instance with specified options. + * + * @param value type + * @param options instance options + * @return RingBuffer object + */ + RRingBufferReactive getRingBuffer(PlainOptions options); + /** * Returns blocking queue instance by name. * * @param type of values - * @param name - name of object + * @param name name of object * @return BlockingQueue object */ RBlockingQueueReactive getBlockingQueue(String name); @@ -797,17 +1167,26 @@ public interface RedissonReactiveClient { * using provided codec for queue objects. * * @param type of values - * @param name - name of object - * @param codec - code for values + * @param name name of object + * @param codec code for values * @return BlockingQueue object */ RBlockingQueueReactive getBlockingQueue(String name, Codec codec); + /** + * Returns unbounded blocking queue instance with specified options. + * + * @param type of value + * @param options instance options + * @return BlockingQueue object + */ + RBlockingQueueReactive getBlockingQueue(PlainOptions options); + /** * Returns unbounded blocking deque instance by name. * * @param type of value - * @param name - name of object + * @param name name of object * @return BlockingDeque object */ RBlockingDequeReactive getBlockingDeque(String name); @@ -817,17 +1196,26 @@ public interface RedissonReactiveClient { * using provided codec for deque objects. * * @param type of value - * @param name - name of object - * @param codec - deque objects codec + * @param name name of object + * @param codec deque objects codec * @return BlockingDeque object */ RBlockingDequeReactive getBlockingDeque(String name, Codec codec); + /** + * Returns unbounded blocking deque instance with specified options. + * + * @param type of value + * @param options instance options + * @return BlockingDeque object + */ + RBlockingDequeReactive getBlockingDeque(PlainOptions options); + /** * Returns transfer queue instance by name. * * @param type of values - * @param name - name of object + * @param name name of object * @return TransferQueue object */ RTransferQueueReactive getTransferQueue(String name); @@ -837,17 +1225,26 @@ public interface RedissonReactiveClient { * using provided codec for queue objects. * * @param type of values - * @param name - name of object - * @param codec - code for values + * @param name name of object + * @param codec code for values * @return TransferQueue object */ RTransferQueueReactive getTransferQueue(String name, Codec codec); + /** + * Returns transfer queue instance with specified options. + * + * @param type of values + * @param options instance options + * @return TransferQueue object + */ + RTransferQueueReactive getTransferQueue(PlainOptions options); + /** * Returns deque instance by name. * * @param type of values - * @param name - name of object + * @param name name of object * @return Deque object */ RDequeReactive getDeque(String name); @@ -857,12 +1254,21 @@ public interface RedissonReactiveClient { * using provided codec for deque objects. * * @param type of values - * @param name - name of object - * @param codec - coded for values + * @param name name of object + * @param codec coded for values * @return Deque object */ RDequeReactive getDeque(String name, Codec codec); + /** + * Returns unbounded deque instance with specified options. + * + * @param type of value + * @param options instance options + * @return Deque object + */ + RDequeReactive getDeque(PlainOptions options); + /** * Returns "atomic long" instance by name. * @@ -871,6 +1277,14 @@ public interface RedissonReactiveClient { */ RAtomicLongReactive getAtomicLong(String name); + /** + * Returns atomicLong instance with specified options. + * + * @param options instance options + * @return AtomicLong object + */ + RAtomicLongReactive getAtomicLong(CommonOptions options); + /** * Returns "atomic double" instance by name. * @@ -879,26 +1293,36 @@ public interface RedissonReactiveClient { */ RAtomicDoubleReactive getAtomicDouble(String name); + /** + * Returns atomicDouble instance with specified options. + * + * @param options instance options + * @return AtomicDouble object + */ + RAtomicDoubleReactive getAtomicDouble(CommonOptions options); + /** * Returns object for remote operations prefixed with the default name (redisson_remote_service) * * @return RemoteService object */ + @Deprecated RRemoteService getRemoteService(); /** * Returns object for remote operations prefixed with the default name (redisson_remote_service) * and uses provided codec for method arguments and result. * - * @param codec - codec for response and request + * @param codec codec for response and request * @return RemoteService object */ + @Deprecated RRemoteService getRemoteService(Codec codec); /** * Returns object for remote operations prefixed with the specified name * - * @param name - the name used as the Redis key prefix for the services + * @param name the name used as the Redis key prefix for the services * @return RemoteService object */ RRemoteService getRemoteService(String name); @@ -907,20 +1331,36 @@ public interface RedissonReactiveClient { * Returns object for remote operations prefixed with the specified name * and uses provided codec for method arguments and result. * - * @param name - the name used as the Redis key prefix for the services - * @param codec - codec for response and request + * @param name the name used as the Redis key prefix for the services + * @param codec codec for response and request * @return RemoteService object */ RRemoteService getRemoteService(String name, Codec codec); - + + /** + * Returns object for remote operations prefixed with specified options. + * + * @param options instance options + * @return RemoteService object + */ + RRemoteService getRemoteService(PlainOptions options); + /** * Returns bitSet instance by name. * - * @param name - name of object + * @param name name of object * @return BitSet object */ RBitSetReactive getBitSet(String name); + /** + * Returns bitSet instance with specified options. + * + * @param options instance options + * @return BitSet object + */ + RBitSetReactive getBitSet(CommonOptions options); + /** * Returns interface for Redis Function feature * @@ -931,11 +1371,19 @@ public interface RedissonReactiveClient { /** * Returns interface for Redis Function feature using provided codec * - * @param codec - codec for params and result + * @param codec codec for params and result * @return function interface */ RFunctionReactive getFunction(Codec codec); + /** + * Returns interface for Redis Function feature with specified options. + * + * @param options instance options + * @return function object + */ + RFunctionReactive getFunction(OptionalOptions options); + /** * Returns script operations object * @@ -946,15 +1394,23 @@ public interface RedissonReactiveClient { /** * Returns script operations object using provided codec. * - * @param codec - codec for params and result + * @param codec codec for params and result * @return Script object */ RScriptReactive getScript(Codec codec); - + + /** + * Returns script operations object with specified options. + * + * @param options instance options + * @return Script object + */ + RScriptReactive getScript(OptionalOptions options); + /** * Creates transaction with READ_COMMITTED isolation level. * - * @param options - transaction configuration + * @param options transaction configuration * @return Transaction object */ RTransactionReactive createTransaction(TransactionOptions options); @@ -965,7 +1421,7 @@ public interface RedissonReactiveClient { * * See http://redis.io/topics/pipelining * - * @param options - batch configuration + * @param options batch configuration * @return Batch object */ RBatchReactive createBatch(BatchOptions options); @@ -989,8 +1445,17 @@ public interface RedissonReactiveClient { RKeysReactive getKeys(); /** - * Shuts down Redisson instance NOT Redis server + * Returns interface for operations over Redis keys with specified options. + * Each of Redis/Redisson object is associated with own key. + * + * @return Keys object + */ + RKeysReactive getKeys(KeysOptions options); + + /** + * Use {@link RedissonClient#shutdown()} instead */ + @Deprecated void shutdown(); /** @@ -1003,17 +1468,19 @@ public interface RedissonReactiveClient { Config getConfig(); /** - * Get Redis nodes group for server operations + * Use {@link org.redisson.api.RedissonClient#getRedisNodes(org.redisson.api.redisnode.RedisNodes)} instead * * @return NodesGroup object */ + @Deprecated NodesGroup getNodesGroup(); /** - * Get Redis cluster nodes group for server operations + * Use {@link org.redisson.api.RedissonClient#getRedisNodes(org.redisson.api.redisnode.RedisNodes)} instead * * @return NodesGroup object */ + @Deprecated NodesGroup getClusterNodesGroup(); /** diff --git a/redisson/src/main/java/org/redisson/api/RedissonRxClient.java b/redisson/src/main/java/org/redisson/api/RedissonRxClient.java index 1ceabc187..d237c747c 100644 --- a/redisson/src/main/java/org/redisson/api/RedissonRxClient.java +++ b/redisson/src/main/java/org/redisson/api/RedissonRxClient.java @@ -15,6 +15,7 @@ */ package org.redisson.api; +import org.redisson.api.options.*; import org.redisson.client.codec.Codec; import org.redisson.codec.JsonCodec; import org.redisson.config.Config; @@ -37,7 +38,7 @@ public interface RedissonRxClient { * * @param value type * @param label type - * @param name - name of instance + * @param name name of instance * @return RTimeSeries object */ RTimeSeriesRx getTimeSeries(String name); @@ -48,12 +49,22 @@ public interface RedissonRxClient { * * @param value type * @param label type - * @param name - name of instance - * @param codec - codec for values + * @param name name of instance + * @param codec codec for values * @return RTimeSeries object */ RTimeSeriesRx getTimeSeries(String name, Codec codec); + /** + * Returns time-series instance with specified options. + * + * @param value type + * @param label type + * @param options instance options + * @return RTimeSeries object + */ + RTimeSeriesRx getTimeSeries(PlainOptions options); + /** * Returns stream instance by name *

@@ -74,12 +85,24 @@ public interface RedissonRxClient { * * @param type of key * @param type of value - * @param name - name of stream - * @param codec - codec for entry + * @param name name of stream + * @param codec codec for entry * @return RStream object */ RStreamRx getStream(String name, Codec codec); + /** + * Returns time-series instance with specified options. + *

+ * Requires Redis 5.0.0 and higher. + * + * @param type of key + * @param type of value + * @param options instance options + * @return RStream object + */ + RStreamRx getStream(PlainOptions options); + /** * Returns API for RediSearch module * @@ -94,11 +117,19 @@ public interface RedissonRxClient { */ RSearchRx getSearch(Codec codec); + /** + * Returns API for RediSearch module with specified options. + * + * @param options instance options + * @return RSearch object + */ + RSearchRx getSearch(OptionalOptions options); + /** * Returns geospatial items holder instance by name. * * @param type of value - * @param name - name of object + * @param name name of object * @return Geo object */ RGeoRx getGeo(String name); @@ -108,12 +139,21 @@ public interface RedissonRxClient { * using provided codec for geospatial members. * * @param type of value - * @param name - name of object - * @param codec - codec for value + * @param name name of object + * @param codec codec for value * @return Geo object */ RGeoRx getGeo(String name, Codec codec); - + + /** + * Returns geospatial items holder instance with specified options. + * + * @param type of value + * @param options instance options + * @return Geo object + */ + RGeoRx getGeo(PlainOptions options); + /** * Returns rate limiter instance by name * @@ -122,6 +162,14 @@ public interface RedissonRxClient { */ RRateLimiterRx getRateLimiter(String name); + /** + * Returns rate limiter instance with specified options. + * + * @param options instance options + * @return RateLimiter object + */ + RRateLimiterRx getRateLimiter(CommonOptions options); + /** * Returns binary stream holder instance by name * @@ -130,33 +178,68 @@ public interface RedissonRxClient { */ RBinaryStreamRx getBinaryStream(String name); + /** + * Returns binary stream holder instance with specified options. + * + * @param options instance options + * @return BinaryStream object + */ + RBinaryStreamRx getBinaryStream(CommonOptions options); + /** * Returns semaphore instance by name * - * @param name - name of object + * @param name name of object * @return Semaphore object */ RSemaphoreRx getSemaphore(String name); - + + /** + * Returns semaphore instance with specified options. + * + * @param options instance options + * @return Semaphore object + */ + RSemaphoreRx getSemaphore(CommonOptions options); + /** * Returns semaphore instance by name. * Supports lease time parameter for each acquired permit. * - * @param name - name of object + * @param name name of object * @return PermitExpirableSemaphore object */ RPermitExpirableSemaphoreRx getPermitExpirableSemaphore(String name); - + + /** + * Returns semaphore instance with specified options. + * Supports lease time parameter for each acquired permit. + * + * @param options instance options + * @return PermitExpirableSemaphore object + */ + RPermitExpirableSemaphoreRx getPermitExpirableSemaphore(CommonOptions options); + /** * Returns ReadWriteLock instance by name. *

* To increase reliability during failover, all operations wait for propagation to all Redis slaves. * - * @param name - name of object + * @param name name of object * @return Lock object */ RReadWriteLockRx getReadWriteLock(String name); - + + /** + * Returns ReadWriteLock instance with specified options. + *

+ * To increase reliability during failover, all operations wait for propagation to all Redis slaves. + * + * @param options instance options + * @return Lock object + */ + RReadWriteLockRx getReadWriteLock(CommonOptions options); + /** * Returns Lock instance by name. *

@@ -164,10 +247,22 @@ public interface RedissonRxClient { *

* To increase reliability during failover, all operations wait for propagation to all Redis slaves. * - * @param name - name of object + * @param name name of object * @return Lock object */ RLockRx getFairLock(String name); + + /** + * Returns Lock instance with specified options. + *

+ * Implements a fair locking so it guarantees an acquire order by threads. + *

+ * To increase reliability during failover, all operations wait for propagation to all Redis slaves. + * + * @param options instance options + * @return Lock object + */ + RLockRx getFairLock(CommonOptions options); /** * Returns Lock instance by name. @@ -176,11 +271,23 @@ public interface RedissonRxClient { *

* To increase reliability during failover, all operations wait for propagation to all Redis slaves. * - * @param name - name of object + * @param name name of object * @return Lock object */ RLockRx getLock(String name); + /** + * Returns Lock instance with specified options. + *

+ * Implements a non-fair locking so doesn't guarantees an acquire order by threads. + *

+ * To increase reliability during failover, all operations wait for propagation to all Redis slaves. + * + * @param options instance options + * @return Lock object + */ + RLockRx getLock(CommonOptions options); + /** * Returns Spin lock instance by name. *

@@ -188,7 +295,7 @@ public interface RedissonRxClient { *

* Lock doesn't use a pub/sub mechanism * - * @param name - name of object + * @param name name of object * @return Lock object */ RLockRx getSpinLock(String name); @@ -200,7 +307,7 @@ public interface RedissonRxClient { *

* Lock doesn't use a pub/sub mechanism * - * @param name - name of object + * @param name name of object * @return Lock object */ RLockRx getSpinLock(String name, LockOptions.BackOff backOff); @@ -215,10 +322,20 @@ public interface RedissonRxClient { */ RFencedLockRx getFencedLock(String name); + /** + * Returns Fenced Lock instance with specified options.. + *

+ * Implements a non-fair locking so doesn't guarantee an acquire order by threads. + * + * @param options instance options + * @return Lock object + */ + RFencedLockRx getFencedLock(CommonOptions options); + /** * Returns MultiLock instance associated with specified locks * - * @param locks - collection of locks + * @param locks collection of locks * @return MultiLock object */ RLockRx getMultiLock(RLockRx... locks); @@ -238,11 +355,19 @@ public interface RedissonRxClient { /** * Returns CountDownLatch instance by name. * - * @param name - name of object + * @param name name of object * @return CountDownLatch object */ RCountDownLatchRx getCountDownLatch(String name); + /** + * Returns countDownLatch instance with specified options. + * + * @param options instance options + * @return CountDownLatch object + */ + RCountDownLatchRx getCountDownLatch(CommonOptions options); + /** * Returns set-based cache instance by name. * Supports value eviction with a given TTL value. @@ -250,7 +375,7 @@ public interface RedissonRxClient { *

If eviction is not required then it's better to use regular map {@link #getSet(String, Codec)}.

* * @param type of values - * @param name - name of object + * @param name name of object * @return SetCache object */ RSetCacheRx getSetCache(String name); @@ -262,12 +387,24 @@ public interface RedissonRxClient { *

If eviction is not required then it's better to use regular map {@link #getSet(String, Codec)}.

* * @param type of values - * @param name - name of object - * @param codec - codec for values + * @param name name of object + * @param codec codec for values * @return SetCache object */ RSetCacheRx getSetCache(String name, Codec codec); + /** + * Returns set-based cache instance with specified options. + * Supports value eviction with a given TTL value. + * + *

If eviction is not required then it's better to use regular map {@link #getSet(PlainOptions)}.

+ * + * @param type of value + * @param options instance options + * @return SetCache object + */ + RSetCacheRx getSetCache(PlainOptions options); + /** * Returns map-based cache instance by name * using provided codec for both cache keys and values. @@ -277,8 +414,8 @@ public interface RedissonRxClient { * * @param type of keys * @param type of values - * @param name - name of object - * @param codec - codec for values + * @param name name of object + * @param codec codec for values * @return MapCache object */ RMapCacheRx getMapCache(String name, Codec codec); @@ -292,11 +429,12 @@ public interface RedissonRxClient { * * @param type of key * @param type of value - * @param name - object name - * @param codec - codec for keys and values - * @param options - map options + * @param name object name + * @param codec codec for keys and values + * @param options map options * @return MapCache object */ + @Deprecated RMapCacheRx getMapCache(String name, Codec codec, MapCacheOptions options); /** @@ -307,7 +445,7 @@ public interface RedissonRxClient { * * @param type of keys * @param type of values - * @param name - name of object + * @param name name of object * @return MapCache object */ RMapCacheRx getMapCache(String name); @@ -320,17 +458,31 @@ public interface RedissonRxClient { * * @param type of key * @param type of value - * @param name - name of object - * @param options - map options + * @param name name of object + * @param options map options * @return MapCache object */ + @Deprecated RMapCacheRx getMapCache(String name, MapCacheOptions options); - + + /** + * Returns map-based cache instance with specified options. + * Supports entry eviction with a given MaxIdleTime and TTL settings. + *

+ * If eviction is not required then it's better to use regular map {@link #getMap(org.redisson.api.options.MapOptions)}.

+ * + * @param type of key + * @param type of value + * @param options instance options + * @return MapCache object + */ + RMapCacheRx getMapCache(org.redisson.api.options.MapCacheOptions options); + /** * Returns object holder instance by name * * @param type of value - * @param name - name of object + * @param name name of object * @return Bucket object */ RBucketRx getBucket(String name); @@ -340,12 +492,21 @@ public interface RedissonRxClient { * using provided codec for object. * * @param type of value - * @param name - name of object - * @param codec - codec for value + * @param name name of object + * @param codec codec for value * @return Bucket object */ RBucketRx getBucket(String name, Codec codec); + /** + * Returns object holder instance with specified options. + * + * @param type of value + * @param options instance options + * @return Bucket object + */ + RBucketRx getBucket(PlainOptions options); + /** * Returns interface for mass operations with Bucket objects. * @@ -357,11 +518,19 @@ public interface RedissonRxClient { * Returns interface for mass operations with Bucket objects * using provided codec for object. * - * @param codec - codec for bucket objects + * @param codec codec for bucket objects * @return Buckets */ RBucketsRx getBuckets(Codec codec); + /** + * Returns API for mass operations over Bucket objects with specified options. + * + * @param options instance options + * @return Buckets object + */ + RBucketsRx getBuckets(OptionalOptions options); + /** * Returns JSON data holder instance by name using provided codec. * @@ -372,11 +541,20 @@ public interface RedissonRxClient { */ RJsonBucketRx getJsonBucket(String name, JsonCodec codec); + /** + * Returns JSON data holder instance with specified options. + * + * @param type of value + * @param options instance options + * @return JsonBucket object + */ + RJsonBucketRx getJsonBucket(JsonBucketOptions options); + /** * Returns HyperLogLog instance by name. * * @param type of values - * @param name - name of object + * @param name name of object * @return HyperLogLog object */ RHyperLogLogRx getHyperLogLog(String name); @@ -386,25 +564,42 @@ public interface RedissonRxClient { * using provided codec for hll objects. * * @param type of values - * @param name - name of object - * @param codec - codec of values + * @param name name of object + * @param codec codec of values * @return HyperLogLog object */ RHyperLogLogRx getHyperLogLog(String name, Codec codec); + /** + * Returns HyperLogLog instance with specified options. + * + * @param type of value + * @param options instance options + * @return HyperLogLog object + */ + RHyperLogLogRx getHyperLogLog(PlainOptions options); + /** * Returns id generator by name. * - * @param name - name of object + * @param name name of object * @return IdGenerator object */ RIdGeneratorRx getIdGenerator(String name); + /** + * Returns id generator instance with specified options. + * + * @param options instance options + * @return IdGenerator object + */ + RIdGeneratorRx getIdGenerator(CommonOptions options); + /** * Returns list instance by name. * * @param type of values - * @param name - name of object + * @param name name of object * @return List object */ RListRx getList(String name); @@ -414,18 +609,27 @@ public interface RedissonRxClient { * using provided codec for list objects. * * @param type of values - * @param name - name of object - * @param codec - codec for values + * @param name name of object + * @param codec codec for values * @return List object */ RListRx getList(String name, Codec codec); + /** + * Returns list instance with specified options. + * + * @param type of value + * @param options instance options + * @return List object + */ + RListRx getList(PlainOptions options); + /** * Returns List based Multimap instance by name. * * @param type of key * @param type of value - * @param name - name of object + * @param name name of object * @return ListMultimap object */ RListMultimapRx getListMultimap(String name); @@ -436,12 +640,22 @@ public interface RedissonRxClient { * * @param type of key * @param type of value - * @param name - name of object - * @param codec - codec for keys and values + * @param name name of object + * @param codec codec for keys and values * @return RListMultimapReactive object */ RListMultimapRx getListMultimap(String name, Codec codec); + /** + * Returns List based Multimap instance with specified options. + * + * @param type of key + * @param type of value + * @param options instance options + * @return ListMultimap object + */ + RListMultimapRx getListMultimap(PlainOptions options); + /** * Returns List based Multimap cache instance by name. * Supports key eviction by specifying a time to live. @@ -449,7 +663,7 @@ public interface RedissonRxClient { * * @param type of key * @param type of value - * @param name - name of object + * @param name name of object * @return RListMultimapCacheRx object */ RListMultimapCacheRx getListMultimapCache(String name); @@ -461,18 +675,31 @@ public interface RedissonRxClient { * * @param type of key * @param type of value - * @param name - name of object - * @param codec - codec for keys and values + * @param name name of object + * @param codec codec for keys and values * @return RListMultimapCacheRx object */ RListMultimapCacheRx getListMultimapCache(String name, Codec codec); + /** + * Returns List based Multimap instance by name. + * Supports key-entry eviction with a given TTL value. + * + *

If eviction is not required then it's better to use regular map {@link #getSetMultimap(String)}.

+ * + * @param type of key + * @param type of value + * @param options instance options + * @return ListMultimapCache object + */ + RListMultimapCacheRx getListMultimapCache(PlainOptions options); + /** * Returns Set based Multimap instance by name. * * @param type of key * @param type of value - * @param name - name of object + * @param name name of object * @return SetMultimap object */ RSetMultimapRx getSetMultimap(String name); @@ -483,12 +710,22 @@ public interface RedissonRxClient { * * @param type of key * @param type of value - * @param name - name of object - * @param codec - codec for keys and values + * @param name name of object + * @param codec codec for keys and values * @return SetMultimap object */ RSetMultimapRx getSetMultimap(String name, Codec codec); + /** + * Returns Set based Multimap instance with specified options. + * + * @param type of key + * @param type of value + * @param options instance options + * @return SetMultimap object + */ + RSetMultimapRx getSetMultimap(PlainOptions options); + /** * Returns Set based Multimap cache instance by name. * Supports key eviction by specifying a time to live. @@ -496,7 +733,7 @@ public interface RedissonRxClient { * * @param type of key * @param type of value - * @param name - name of object + * @param name name of object * @return RSetMultimapCacheRx object */ RSetMultimapCacheRx getSetMultimapCache(String name); @@ -508,18 +745,31 @@ public interface RedissonRxClient { * * @param type of key * @param type of value - * @param name - name of object - * @param codec - codec for keys and values + * @param name name of object + * @param codec codec for keys and values * @return RSetMultimapCacheRx object */ RSetMultimapCacheRx getSetMultimapCache(String name, Codec codec); + /** + * Returns Set based Multimap instance with specified options. + * Supports key-entry eviction with a given TTL value. + * + *

If eviction is not required then it's better to use regular map {@link #getSetMultimap(PlainOptions)}.

+ * + * @param type of key + * @param type of value + * @param options instance options + * @return SetMultimapCache object + */ + RSetMultimapCacheRx getSetMultimapCache(PlainOptions options); + /** * Returns map instance by name. * * @param type of keys * @param type of values - * @param name - name of object + * @param name name of object * @return Map object */ RMapRx getMap(String name); @@ -529,10 +779,11 @@ public interface RedissonRxClient { * * @param type of key * @param type of value - * @param name - name of object - * @param options - map options + * @param name name of object + * @param options map options * @return Map object */ + @Deprecated RMapRx getMap(String name, MapOptions options); /** @@ -541,8 +792,8 @@ public interface RedissonRxClient { * * @param type of keys * @param type of values - * @param name - name of object - * @param codec - codec for keys and values + * @param name name of object + * @param codec codec for keys and values * @return Map object */ RMapRx getMap(String name, Codec codec); @@ -553,23 +804,35 @@ public interface RedissonRxClient { * * @param type of key * @param type of value - * @param name - name of object - * @param codec - codec for keys and values - * @param options - map options + * @param name name of object + * @param codec codec for keys and values + * @param options map options * @return Map object */ + @Deprecated RMapRx getMap(String name, Codec codec, MapOptions options); + /** + * Returns map instance by name. + * + * @param type of key + * @param type of value + * @param options instance options + * @return Map object + */ + RMapRx getMap(org.redisson.api.options.MapOptions options); + /** * Returns local cached map instance by name. * Configured by parameters of options-object. * * @param type of key * @param type of value - * @param name - name of object - * @param options - local map options + * @param name name of object + * @param options local map options * @return LocalCachedMap object */ + @Deprecated RLocalCachedMapRx getLocalCachedMap(String name, LocalCachedMapOptions options); /** @@ -578,18 +841,29 @@ public interface RedissonRxClient { * * @param type of key * @param type of value - * @param name - name of object - * @param codec - codec for keys and values - * @param options - local map options + * @param name name of object + * @param codec codec for keys and values + * @param options local map options * @return LocalCachedMap object */ + @Deprecated RLocalCachedMapRx getLocalCachedMap(String name, Codec codec, LocalCachedMapOptions options); + /** + * Returns local cached map instance with specified options. + * + * @param type of key + * @param type of value + * @param options instance options + * @return LocalCachedMap object + */ + RLocalCachedMapRx getLocalCachedMap(org.redisson.api.options.LocalCachedMapOptions options); + /** * Returns set instance by name. * * @param type of values - * @param name - name of object + * @param name name of object * @return Set object */ RSetRx getSet(String name); @@ -599,12 +873,21 @@ public interface RedissonRxClient { * using provided codec for set objects. * * @param type of values - * @param name - name of set - * @param codec - codec for values + * @param name name of set + * @param codec codec for values * @return Set object */ RSetRx getSet(String name, Codec codec); + /** + * Returns set instance with specified options. + * + * @param type of value + * @param options instance options + * @return Set object + */ + RSetRx getSet(PlainOptions options); + /** * Returns Redis Sorted Set instance by name. * This sorted set sorts objects by object score. @@ -621,29 +904,49 @@ public interface RedissonRxClient { * This sorted set sorts objects by object score. * * @param type of values - * @param name - name of scored sorted set - * @param codec - codec for values + * @param name name of scored sorted set + * @param codec codec for values * @return ScoredSortedSet object */ RScoredSortedSetRx getScoredSortedSet(String name, Codec codec); + /** + * Returns Redis Sorted Set instance with specified options. + * This sorted set sorts objects by object score. + * + * @param type of value + * @param options instance options + * @return ScoredSortedSet object + */ + RScoredSortedSetRx getScoredSortedSet(PlainOptions options); + /** * Returns String based Redis Sorted Set instance by name * All elements are inserted with the same score during addition, * in order to force lexicographical ordering * - * @param name - name of object + * @param name name of object * @return LexSortedSet object */ RLexSortedSetRx getLexSortedSet(String name); + /** + * Returns String based Redis Sorted Set instance with specified options. + * All elements are inserted with the same score during addition, + * in order to force lexicographical ordering + * + * @param options instance options + * @return LexSortedSet object + */ + RLexSortedSetRx getLexSortedSet(CommonOptions options); + /** * Returns Sharded Topic instance by name. *

* Messages are delivered to message listeners connected to the same Topic. *

* - * @param name - name of object + * @param name name of object * @return Topic object */ RShardedTopicRx getShardedTopic(String name); @@ -654,16 +957,27 @@ public interface RedissonRxClient { * Messages are delivered to message listeners connected to the same Topic. *

* - * @param name - name of object - * @param codec - codec for message + * @param name name of object + * @param codec codec for message * @return Topic object */ RShardedTopicRx getShardedTopic(String name, Codec codec); + /** + * Returns Sharded Topic instance with specified options. + *

+ * Messages are delivered to message listeners connected to the same Topic. + *

+ * + * @param options instance options + * @return Topic object + */ + RShardedTopicRx getShardedTopic(PlainOptions options); + /** * Returns topic instance by name. * - * @param name - name of object + * @param name name of object * @return Topic object */ RTopicRx getTopic(String name); @@ -672,12 +986,23 @@ public interface RedissonRxClient { * Returns topic instance by name * using provided codec for messages. * - * @param name - name of object - * @param codec - codec for message + * @param name name of object + * @param codec codec for message * @return Topic object */ RTopicRx getTopic(String name, Codec codec); + /** + * Returns topic instance with specified options. + *

+ * Messages are delivered to message listeners connected to the same Topic. + *

+ * + * @param options instance options + * @return Topic object + */ + RTopicRx getTopic(PlainOptions options); + /** * Returns reliable topic instance by name. *

@@ -686,7 +1011,7 @@ public interface RedissonRxClient { *

* Requires Redis 5.0.0 and higher. * - * @param name - name of object + * @param name name of object * @return ReliableTopic object */ RReliableTopicRx getReliableTopic(String name); @@ -700,12 +1025,25 @@ public interface RedissonRxClient { *

* Requires Redis 5.0.0 and higher. * - * @param name - name of object - * @param codec - codec for message + * @param name name of object + * @param codec codec for message * @return ReliableTopic object */ RReliableTopicRx getReliableTopic(String name, Codec codec); + /** + * Returns reliable topic instance with specified options. + *

+ * Dedicated Redis connection is allocated per instance (subscriber) of this object. + * Messages are delivered to all listeners attached to the same Redis setup. + *

+ * Requires Redis 5.0.0 and higher. + * + * @param options instance options + * @return ReliableTopic object + */ + RReliableTopicRx getReliableTopic(PlainOptions options); + /** * Returns topic instance satisfies by pattern name. * @@ -729,16 +1067,29 @@ public interface RedissonRxClient { * h[ae]llo subscribes to hello and hallo, but not hillo * * @param pattern of the topic - * @param codec - codec for message + * @param codec codec for message * @return PatternTopic object */ RPatternTopicRx getPatternTopic(String pattern, Codec codec); + /** + * Returns topic instance satisfies pattern name and specified options.. + * + * Supported glob-style patterns: + * h?llo subscribes to hello, hallo and hxllo + * h*llo subscribes to hllo and heeeello + * h[ae]llo subscribes to hello and hallo, but not hillo + * + * @param options instance options + * @return PatterTopic object + */ + RPatternTopicRx getPatternTopic(PatternTopicOptions options); + /** * Returns queue instance by name. * * @param type of values - * @param name - name of object + * @param name name of object * @return Queue object */ RQueueRx getQueue(String name); @@ -748,17 +1099,26 @@ public interface RedissonRxClient { * using provided codec for queue objects. * * @param type of values - * @param name - name of object - * @param codec - codec for values + * @param name name of object + * @param codec codec for values * @return Queue object */ RQueueRx getQueue(String name, Codec codec); + /** + * Returns unbounded queue instance with specified options. + * + * @param type of value + * @param options instance options + * @return queue object + */ + RQueueRx getQueue(PlainOptions options); + /** * Returns RingBuffer based queue. * * @param value type - * @param name - name of object + * @param name name of object * @return RingBuffer object */ RRingBufferRx getRingBuffer(String name); @@ -767,17 +1127,26 @@ public interface RedissonRxClient { * Returns RingBuffer based queue. * * @param value type - * @param name - name of object - * @param codec - codec for values + * @param name name of object + * @param codec codec for values * @return RingBuffer object */ RRingBufferRx getRingBuffer(String name, Codec codec); - + + /** + * Returns RingBuffer based queue instance with specified options. + * + * @param value type + * @param options instance options + * @return RingBuffer object + */ + RRingBufferRx getRingBuffer(PlainOptions options); + /** * Returns blocking queue instance by name. * * @param type of values - * @param name - name of object + * @param name name of object * @return BlockingQueue object */ RBlockingQueueRx getBlockingQueue(String name); @@ -787,17 +1156,26 @@ public interface RedissonRxClient { * using provided codec for queue objects. * * @param type of values - * @param name - name of object - * @param codec - code for values + * @param name name of object + * @param codec code for values * @return BlockingQueue object */ RBlockingQueueRx getBlockingQueue(String name, Codec codec); + /** + * Returns unbounded blocking queue instance with specified options. + * + * @param type of value + * @param options instance options + * @return BlockingQueue object + */ + RBlockingQueueRx getBlockingQueue(PlainOptions options); + /** * Returns unbounded blocking deque instance by name. * * @param type of value - * @param name - name of object + * @param name name of object * @return BlockingDeque object */ RBlockingDequeRx getBlockingDeque(String name); @@ -807,17 +1185,26 @@ public interface RedissonRxClient { * using provided codec for deque objects. * * @param type of value - * @param name - name of object - * @param codec - deque objects codec + * @param name name of object + * @param codec deque objects codec * @return BlockingDeque object */ RBlockingDequeRx getBlockingDeque(String name, Codec codec); + /** + * Returns unbounded blocking deque instance with specified options. + * + * @param type of value + * @param options instance options + * @return BlockingDeque object + */ + RBlockingDequeRx getBlockingDeque(PlainOptions options); + /** * Returns transfer queue instance by name. * * @param type of values - * @param name - name of object + * @param name name of object * @return TransferQueue object */ RTransferQueueRx getTransferQueue(String name); @@ -827,17 +1214,26 @@ public interface RedissonRxClient { * using provided codec for queue objects. * * @param type of values - * @param name - name of object - * @param codec - code for values + * @param name name of object + * @param codec code for values * @return TransferQueue object */ RTransferQueueRx getTransferQueue(String name, Codec codec); + /** + * Returns transfer queue instance with specified options. + * + * @param type of values + * @param options instance options + * @return TransferQueue object + */ + RTransferQueueRx getTransferQueue(PlainOptions options); + /** * Returns deque instance by name. * * @param type of values - * @param name - name of object + * @param name name of object * @return Deque object */ RDequeRx getDeque(String name); @@ -847,12 +1243,21 @@ public interface RedissonRxClient { * using provided codec for deque objects. * * @param type of values - * @param name - name of object - * @param codec - coded for values + * @param name name of object + * @param codec coded for values * @return Deque object */ RDequeRx getDeque(String name, Codec codec); + /** + * Returns unbounded deque instance with specified options. + * + * @param type of value + * @param options instance options + * @return Deque object + */ + RDequeRx getDeque(PlainOptions options); + /** * Returns "atomic long" instance by name. * @@ -861,6 +1266,14 @@ public interface RedissonRxClient { */ RAtomicLongRx getAtomicLong(String name); + /** + * Returns atomicLong instance with specified options. + * + * @param options instance options + * @return AtomicLong object + */ + RAtomicLongRx getAtomicLong(CommonOptions options); + /** * Returns "atomic double" instance by name. * @@ -869,26 +1282,36 @@ public interface RedissonRxClient { */ RAtomicDoubleRx getAtomicDouble(String name); + /** + * Returns atomicDouble instance with specified options. + * + * @param options instance options + * @return AtomicDouble object + */ + RAtomicDoubleRx getAtomicDouble(CommonOptions options); + /** * Returns object for remote operations prefixed with the default name (redisson_remote_service) * * @return RemoteService object */ + @Deprecated RRemoteService getRemoteService(); /** * Returns object for remote operations prefixed with the default name (redisson_remote_service) * and uses provided codec for method arguments and result. * - * @param codec - codec for response and request + * @param codec codec for response and request * @return RemoteService object */ + @Deprecated RRemoteService getRemoteService(Codec codec); /** * Returns object for remote operations prefixed with the specified name * - * @param name - the name used as the Redis key prefix for the services + * @param name the name used as the Redis key prefix for the services * @return RemoteService object */ RRemoteService getRemoteService(String name); @@ -897,20 +1320,36 @@ public interface RedissonRxClient { * Returns object for remote operations prefixed with the specified name * and uses provided codec for method arguments and result. * - * @param name - the name used as the Redis key prefix for the services - * @param codec - codec for response and request + * @param name the name used as the Redis key prefix for the services + * @param codec codec for response and request * @return RemoteService object */ RRemoteService getRemoteService(String name, Codec codec); - + + /** + * Returns object for remote operations prefixed with specified options. + * + * @param options instance options + * @return RemoteService object + */ + RRemoteService getRemoteService(PlainOptions options); + /** * Returns bitSet instance by name. * - * @param name - name of object + * @param name name of object * @return BitSet object */ RBitSetRx getBitSet(String name); + /** + * Returns bitSet instance with specified options. + * + * @param options instance options + * @return BitSet object + */ + RBitSetRx getBitSet(CommonOptions options); + /** * Returns interface for Redis Function feature * @@ -921,11 +1360,19 @@ public interface RedissonRxClient { /** * Returns interface for Redis Function feature using provided codec * - * @param codec - codec for params and result + * @param codec codec for params and result * @return function interface */ RFunctionRx getFunction(Codec codec); + /** + * Returns interface for Redis Function feature with specified options. + * + * @param options instance options + * @return function object + */ + RFunctionRx getFunction(OptionalOptions options); + /** * Returns script operations object * @@ -936,15 +1383,23 @@ public interface RedissonRxClient { /** * Returns script operations object using provided codec. * - * @param codec - codec for params and result + * @param codec codec for params and result * @return Script object */ RScriptRx getScript(Codec codec); - + + /** + * Returns script operations object with specified options. + * + * @param options instance options + * @return Script object + */ + RScriptRx getScript(OptionalOptions options); + /** * Creates transaction with READ_COMMITTED isolation level. * - * @param options - transaction configuration + * @param options transaction configuration * @return Transaction object */ RTransactionRx createTransaction(TransactionOptions options); @@ -955,7 +1410,7 @@ public interface RedissonRxClient { * * See http://redis.io/topics/pipelining * - * @param options - batch configuration + * @param options batch configuration * @return Batch object */ RBatchRx createBatch(BatchOptions options); @@ -979,8 +1434,17 @@ public interface RedissonRxClient { RKeysRx getKeys(); /** - * Shuts down Redisson instance NOT Redis server + * Returns interface for operations over Redis keys with specified options. + * Each of Redis/Redisson object is associated with own key. + * + * @return Keys object + */ + RKeysRx getKeys(KeysOptions options); + + /** + * Use {@link RedissonClient#shutdown()} instead */ + @Deprecated void shutdown(); /** @@ -993,17 +1457,19 @@ public interface RedissonRxClient { Config getConfig(); /** - * Get Redis nodes group for server operations + * Use {@link org.redisson.api.RedissonClient#getRedisNodes(org.redisson.api.redisnode.RedisNodes)} instead * * @return NodesGroup object */ + @Deprecated NodesGroup getNodesGroup(); /** - * Get Redis cluster nodes group for server operations + * Use {@link org.redisson.api.RedissonClient#getRedisNodes(org.redisson.api.redisnode.RedisNodes)} instead * * @return NodesGroup object */ + @Deprecated NodesGroup getClusterNodesGroup(); /** diff --git a/redisson/src/main/java/org/redisson/api/map/WriteMode.java b/redisson/src/main/java/org/redisson/api/map/WriteMode.java new file mode 100644 index 000000000..43ef87613 --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/map/WriteMode.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.map; + +/** + * + * @author Nikita Koksharov + * + */ +public enum WriteMode { + + /** + * In write behind mode all data written in map object + * also written using MapWriter in asynchronous mode. + */ + WRITE_BEHIND, + + /** + * In write through mode all write operations for map object + * are synchronized with MapWriter write operations. + * If MapWriter throws an error then it will be re-thrown to Map operation caller. + */ + WRITE_THROUGH + +} diff --git a/redisson/src/main/java/org/redisson/api/options/BaseMapOptions.java b/redisson/src/main/java/org/redisson/api/options/BaseMapOptions.java new file mode 100644 index 000000000..ecb19be61 --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/BaseMapOptions.java @@ -0,0 +1,144 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +import org.redisson.api.map.*; +import org.redisson.client.codec.Codec; + +import java.time.Duration; + +/** + * + * @author Nikita Koksharov + * + */ +class BaseMapOptions, K, V> extends BaseOptions + implements ExMapOptions { + + private int writeRetryAttempts; + private MapWriter writer; + private MapWriterAsync writerAsync; + private int writeBehindBatchSize; + private int writeBehindDelay; + private WriteMode writeMode; + private long writeRetryInterval; + private MapLoader loader; + private MapLoaderAsync loaderAsync; + + public T writer(MapWriter writer) { + if (writer != null) { + org.redisson.api.MapOptions options = (org.redisson.api.MapOptions) org.redisson.api.MapOptions.defaults() + .writerRetryAttempts(getWriteRetryAttempts()) + .writerRetryInterval(Duration.ofMillis(getWriteRetryInterval())); + this.writer = new RetryableMapWriter<>(options, writer); + } + return (T) this; + } + public MapWriter getWriter() { + return writer; + } + + public T writerAsync(MapWriterAsync writer) { + if (writer != null) { + org.redisson.api.MapOptions options = (org.redisson.api.MapOptions) org.redisson.api.MapOptions.defaults() + .writerRetryAttempts(getWriteRetryAttempts()) + .writerRetryInterval(Duration.ofMillis(getWriteRetryInterval())); + this.writerAsync = new RetryableMapWriterAsync<>(options, writer); + } + return (T) this; + } + public MapWriterAsync getWriterAsync() { + return writerAsync; + } + + public T writeBehindBatchSize(int writeBehindBatchSize) { + this.writeBehindBatchSize = writeBehindBatchSize; + return (T) this; + } + public int getWriteBehindBatchSize() { + return writeBehindBatchSize; + } + + public T writeBehindDelay(int writeBehindDelay) { + this.writeBehindDelay = writeBehindDelay; + return (T) this; + } + public int getWriteBehindDelay() { + return writeBehindDelay; + } + + public T writeMode(WriteMode writeMode) { + this.writeMode = writeMode; + return (T) this; + } + public WriteMode getWriteMode() { + return writeMode; + } + + public int getWriteRetryAttempts() { + return writeRetryAttempts; + } + + /** + * Sets max retry attempts for {@link RetryableMapWriter} or {@link RetryableMapWriterAsync} + * + * @param writerRetryAttempts object + * @return MapOptions instance + */ + public T writeRetryAttempts(int writerRetryAttempts) { + if (writerRetryAttempts <= 0){ + throw new IllegalArgumentException("writerRetryAttempts must be bigger than 0"); + } + this.writeRetryAttempts = writerRetryAttempts; + return (T) this; + } + + public long getWriteRetryInterval() { + return writeRetryInterval; + } + + public T writeRetryInterval(Duration writerRetryInterval) { + if (writerRetryInterval.isNegative()) { + throw new IllegalArgumentException("writerRetryInterval must be positive"); + } + this.writeRetryInterval = writerRetryInterval.toMillis(); + return (T) this; + } + + /** + * Sets {@link MapLoader} object. + * + * @param loader object + * @return MapOptions instance + */ + public T loader(MapLoader loader) { + this.loader = loader; + return (T) this; + } + public MapLoader getLoader() { + return loader; + } + + public T loaderAsync(MapLoaderAsync loaderAsync) { + this.loaderAsync = loaderAsync; + return (T) this; + } + + public MapLoaderAsync getLoaderAsync() { + return loaderAsync; + } + +} diff --git a/redisson/src/main/java/org/redisson/api/options/BaseOptions.java b/redisson/src/main/java/org/redisson/api/options/BaseOptions.java new file mode 100644 index 000000000..fa12717aa --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/BaseOptions.java @@ -0,0 +1,72 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +import java.time.Duration; + +/** + * + * @author Nikita Koksharov + * + */ +class BaseOptions, C> implements CodecOptions, ObjectParams { + + private C codec; + private int timeout; + private int retryAttempts; + private int retryInterval; + + @Override + public T codec(C codec) { + this.codec = codec; + return (T) this; + } + + @Override + public T timeout(Duration timeout) { + this.timeout = (int) timeout.toMillis(); + return (T) this; + } + + @Override + public T retryAttempts(int retryAttempts) { + this.retryAttempts = retryAttempts; + return (T) this; + } + + @Override + public T retryInterval(Duration interval) { + this.retryInterval = (int) interval.toMillis(); + return (T) this; + } + + public int getTimeout() { + return timeout; + } + + public int getRetryAttempts() { + return retryAttempts; + } + + public int getRetryInterval() { + return retryInterval; + } + + public C getCodec() { + return codec; + } + +} diff --git a/redisson/src/main/java/org/redisson/api/options/CodecOptions.java b/redisson/src/main/java/org/redisson/api/options/CodecOptions.java new file mode 100644 index 000000000..7953f5614 --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/CodecOptions.java @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +/** + * + * @author Nikita Koksharov + * + */ +public interface CodecOptions, C> extends InvocationOptions { + + /** + * Defines codec used for data stored in Redis + * + * @param codec applied to object instance + * @return options object + */ + T codec(C codec); + +} diff --git a/redisson/src/main/java/org/redisson/api/options/CommonOptions.java b/redisson/src/main/java/org/redisson/api/options/CommonOptions.java new file mode 100644 index 000000000..478e027a0 --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/CommonOptions.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +/** + * Object instance options + * + * @author Nikita Koksharov + * + */ +public interface CommonOptions extends InvocationOptions { + + /** + * Creates options with the name of object instance + * + * @param name of object instance + * @return options instance + */ + static CommonOptions name(String name) { + return new CommonParams(name); + } + +} diff --git a/redisson/src/main/java/org/redisson/api/options/CommonParams.java b/redisson/src/main/java/org/redisson/api/options/CommonParams.java new file mode 100644 index 000000000..82196694e --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/CommonParams.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +import org.redisson.client.codec.Codec; + +/** + * + * @author Nikita Koksharov + * + */ +public final class CommonParams extends BaseOptions implements CommonOptions { + + private final String name; + + CommonParams(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} diff --git a/redisson/src/main/java/org/redisson/api/options/ExMapOptions.java b/redisson/src/main/java/org/redisson/api/options/ExMapOptions.java new file mode 100644 index 000000000..a7a7bbec4 --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/ExMapOptions.java @@ -0,0 +1,112 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +import org.redisson.api.map.*; +import org.redisson.client.codec.Codec; + +import java.time.Duration; + +/** + * + * @author Nikita Koksharov + * + * @param returned object type + * @param type of key + * @param type of value + */ +public interface ExMapOptions, K, V> extends CodecOptions { + + /** + * Defines {@link MapWriter} object which is invoked during write operation. + * + * @param writer object + * @return MapOptions instance + */ + T writer(MapWriter writer); + + /** + * Defines {@link MapWriterAsync} object which is invoked during write operation. + * + * @param writer object + * @return MapOptions instance + */ + T writerAsync(MapWriterAsync writer); + /** + * Sets write behind tasks batch size. + * All updates accumulated into a batch of specified size and written with {@link MapWriter}. + *

+ * Default is 50 + * + * @param writeBehindBatchSize size of batch + * @return MapOptions instance + */ + T writeBehindBatchSize(int writeBehindBatchSize); + + /** + * Sets write behind tasks execution delay. + * All updates written with {@link MapWriter} and lag not more than specified delay. + *

+ * Default is 1000 milliseconds + * + * @param writeBehindDelay delay in milliseconds + * @return MapOptions instance + */ + T writeBehindDelay(int writeBehindDelay); + + /** + * Sets write mode. + *

+ * Default is {@link WriteMode#WRITE_THROUGH} + * + * @param writeMode write mode + * @return MapOptions instance + */ + T writeMode(WriteMode writeMode); + + /** + * Sets max write retry attempts + * + * @param writerRetryAttempts object + * @return MapOptions instance + */ + T writeRetryAttempts(int writerRetryAttempts); + + /** + * Sets write retry interval + * + * @param writerRetryInterval {@link Duration} + * @return MapOptions instance + */ + T writeRetryInterval(Duration writerRetryInterval); + + /** + * Sets {@link MapLoader} object. + * + * @param loader object + * @return MapOptions instance + */ + T loader(MapLoader loader); + + /** + * Sets {@link MapLoaderAsync} object. + * + * @param loaderAsync object + * @return MapOptions instance + */ + T loaderAsync(MapLoaderAsync loaderAsync); + +} diff --git a/redisson/src/main/java/org/redisson/api/options/ExecutorOptions.java b/redisson/src/main/java/org/redisson/api/options/ExecutorOptions.java new file mode 100644 index 000000000..eb7166811 --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/ExecutorOptions.java @@ -0,0 +1,66 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +import org.redisson.api.IdGenerator; +import org.redisson.client.codec.Codec; + +import java.time.Duration; + +/** + * {@link org.redisson.api.RExecutorService} instance options + * + * @author Nikita Koksharov + * + */ +public interface ExecutorOptions extends CodecOptions { + + /** + * Creates options with the name of object instance + * + * @param name of object instance + * @return options instance + */ + static ExecutorOptions name(String name) { + return new ExecutorParams(name); + } + + /** + * Defines task retry interval at the end of which task + * is executed again by ExecutorService worker. + *

+ * Counted from the task start moment. + * Applied only if the task was in progress but for some reason + * wasn't marked as completed (successful or unsuccessful). + *

+ * Set 0 to disable. + *

+ * Default is 5 minutes + * + * @param interval value + * @return options instance + */ + ExecutorOptions taskRetryInterval(Duration interval); + + /** + * Defines identifier generator + * + * @param idGenerator identifier generator + * @return options instance + */ + ExecutorOptions idGenerator(IdGenerator idGenerator); + +} diff --git a/redisson/src/main/java/org/redisson/api/options/ExecutorParams.java b/redisson/src/main/java/org/redisson/api/options/ExecutorParams.java new file mode 100644 index 000000000..e4dc066c4 --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/ExecutorParams.java @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +import org.redisson.api.IdGenerator; +import org.redisson.client.codec.Codec; + +import java.time.Duration; + +/** + * + * @author Nikita Koksharov + * + */ +public final class ExecutorParams extends BaseOptions implements ExecutorOptions { + private final String name; + private int taskRetryInterval = 5 * 60000; + private IdGenerator idGenerator = IdGenerator.random(); + + ExecutorParams(String name) { + this.name = name; + } + + @Override + public ExecutorOptions taskRetryInterval(Duration interval) { + this.taskRetryInterval = (int) interval.toMillis(); + return this; + } + + @Override + public ExecutorOptions idGenerator(IdGenerator idGenerator) { + this.idGenerator = idGenerator; + return this; + } + + public String getName() { + return name; + } + + public int getTaskRetryInterval() { + return taskRetryInterval; + } + + public IdGenerator getIdGenerator() { + return idGenerator; + } + +} diff --git a/redisson/src/main/java/org/redisson/api/options/InvocationOptions.java b/redisson/src/main/java/org/redisson/api/options/InvocationOptions.java new file mode 100644 index 000000000..83a680131 --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/InvocationOptions.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +import java.time.Duration; + +/** + * + * @author Nikita Koksharov + * + */ +public interface InvocationOptions> { + + /** + * Defines Redis server response timeout. Starts to countdown + * when a Redis command was successfully sent. + *

+ * Default is the value specified for the same parameter in Redisson configuration + * + * @param timeout Redis server response timeout + * @return options instance + */ + T timeout(Duration timeout); + + /** + * Defines command retry attempts. Error is thrown if + * the Redis command can't be sent to Redis server after retryAttempts. + * But if it sent successfully then responseTimeout is started. + *

+ * Default is the value specified for the same parameter in Redisson configuration + * + * @param retryAttempts command retry attempts + * @return options instance + */ + T retryAttempts(int retryAttempts); + + /** + * Defines time interval for another one attempt to send a Redis command + * if it hasn't already been sent. + * + * @param interval retry time interval + * @return options instance + */ + T retryInterval(Duration interval); + +} diff --git a/redisson/src/main/java/org/redisson/api/options/JsonBucketOptions.java b/redisson/src/main/java/org/redisson/api/options/JsonBucketOptions.java new file mode 100644 index 000000000..c6bfc8231 --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/JsonBucketOptions.java @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +import org.redisson.codec.JsonCodec; + +/** + * {@link org.redisson.api.RJsonBucket} instance options + * + * @author Nikita Koksharov + * + */ +public interface JsonBucketOptions extends CodecOptions, JsonCodec> { + + /** + * Creates options with the name of object instance + * + * @param name of object instance + * @return options instance + */ + static JsonBucketOptions name(String name) { + return new JsonBucketParams<>(name); + } +} diff --git a/redisson/src/main/java/org/redisson/api/options/JsonBucketParams.java b/redisson/src/main/java/org/redisson/api/options/JsonBucketParams.java new file mode 100644 index 000000000..76d61c454 --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/JsonBucketParams.java @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +import org.redisson.codec.JsonCodec; + +/** + * + * @author Nikita Koksharov + * + */ +public final class JsonBucketParams extends BaseOptions, JsonCodec> implements JsonBucketOptions { + + private final String name; + + JsonBucketParams(String name) { + this.name = name; + } + + public String getName() { + return name; + } + +} diff --git a/redisson/src/main/java/org/redisson/api/options/KeysOptions.java b/redisson/src/main/java/org/redisson/api/options/KeysOptions.java new file mode 100644 index 000000000..6881589a9 --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/KeysOptions.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +/** + * {@link org.redisson.api.RKeys} instance options + * + * @author Nikita Koksharov + * + */ +public interface KeysOptions extends InvocationOptions { + + /** + * Creates the default options + * + * @return options instance + */ + static KeysOptions defaults() { + return new KeysParams(); + } + +} diff --git a/redisson/src/main/java/org/redisson/api/options/KeysParams.java b/redisson/src/main/java/org/redisson/api/options/KeysParams.java new file mode 100644 index 000000000..31434d9f7 --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/KeysParams.java @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +import org.redisson.client.codec.Codec; + +/** + * + * @author Nikita Koksharov + * + */ +public final class KeysParams extends BaseOptions implements KeysOptions { + + KeysParams() { + } +} diff --git a/redisson/src/main/java/org/redisson/api/options/LiveObjectOptions.java b/redisson/src/main/java/org/redisson/api/options/LiveObjectOptions.java new file mode 100644 index 000000000..8ee636cb2 --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/LiveObjectOptions.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +/** + * {@link org.redisson.api.RLiveObjectService} instance options + * + * @author Nikita Koksharov + * + */ +public interface LiveObjectOptions extends InvocationOptions { + + /** + * Creates the default options + * + * @return options instance + */ + static LiveObjectOptions defaults() { + return new LiveObjectParams(); + } + +} diff --git a/redisson/src/main/java/org/redisson/api/options/LiveObjectParams.java b/redisson/src/main/java/org/redisson/api/options/LiveObjectParams.java new file mode 100644 index 000000000..126eb8599 --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/LiveObjectParams.java @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +import org.redisson.client.codec.Codec; + +/** + * + * @author Nikita Koksharov + * + */ +public final class LiveObjectParams extends BaseOptions implements LiveObjectOptions { + LiveObjectParams() { + } + +} diff --git a/redisson/src/main/java/org/redisson/api/options/LocalCachedMapOptions.java b/redisson/src/main/java/org/redisson/api/options/LocalCachedMapOptions.java new file mode 100644 index 000000000..79af84ef2 --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/LocalCachedMapOptions.java @@ -0,0 +1,237 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +import java.time.Duration; + +/** + * {@link org.redisson.api.RLocalCachedMap} instance options. + * + * @author Nikita Koksharov + * + * @param key type + * @param value type + */ +public interface LocalCachedMapOptions extends ExMapOptions, K, V> { + + /** + * Various strategies to avoid stale objects in local cache. + * Handle cases when map instance has been disconnected for a while. + * + */ + enum ReconnectionStrategy { + + /** + * No reconnect handling. + */ + NONE, + + /** + * Clear local cache if map instance disconnected. + */ + CLEAR, + + /** + * Store invalidated entry hash in invalidation log for 10 minutes. + * Cache keys for stored invalidated entry hashes will be removed + * if LocalCachedMap instance has been disconnected less than 10 minutes + * or whole local cache will be cleaned otherwise. + */ + LOAD + + } + + enum SyncStrategy { + + /** + * No synchronizations on map changes. + */ + NONE, + + /** + * Invalidate local cache entry across all LocalCachedMap instances on map entry change. Broadcasts map entry hash (16 bytes) to all instances. + */ + INVALIDATE, + + /** + * Update local cache entry across all LocalCachedMap instances on map entry change. Broadcasts full map entry state (Key and Value objects) to all instances. + */ + UPDATE + + } + + enum EvictionPolicy { + + /** + * Local cache without eviction. + */ + NONE, + + /** + * Least Recently Used local cache eviction policy. + */ + LRU, + + /** + * Least Frequently Used local cache eviction policy. + */ + LFU, + + /** + * Local cache eviction policy with Soft Reference used for values. + * All references will be collected by GC + */ + SOFT, + + /** + * Local cache eviction policy with Weak Reference used for values. + * All references will be collected by GC + */ + WEAK + }; + + enum CacheProvider { + + REDISSON, + + CAFFEINE + + } + + enum StoreMode { + + /** + * Store data only in local cache. + */ + LOCALCACHE, + + /** + * Store data only in both Redis and local cache. + */ + LOCALCACHE_REDIS + + } + + /** + * Creates options with the name of object instance + * + * @param name of object instance + * @return options instance + */ + static LocalCachedMapOptions name(String name) { + return new LocalCachedMapParams<>(name); + } + + /** + * Defines local cache size. + *

+ * If size is 0 then local cache is unbounded. + *

+ * If size is -1 then local cache is always empty and doesn't store data. + * + * @param cacheSize size of cache + * @return LocalCachedMapOptions instance + */ + LocalCachedMapOptions cacheSize(int cacheSize); + + /** + * Defines strategy for load missed local cache updates after Redis connection failure. + * + * @param reconnectionStrategy + *

CLEAR - clear local cache if map instance has been disconnected for a while. + *

LOAD - store invalidated entry hash in invalidation log for 10 minutes. Cache keys for stored invalidated entry hashes will be removed if LocalCachedMap instance has been disconnected less than 10 minutes or whole cache will be cleaned otherwise + *

NONE - Default. No reconnection handling + * @return LocalCachedMapOptions instance + */ + LocalCachedMapOptions reconnectionStrategy(ReconnectionStrategy reconnectionStrategy); + + /** + * Defines local cache synchronization strategy. + * + * @param syncStrategy + *

INVALIDATE - Default. Invalidate cache entry across all LocalCachedMap instances on map entry change + *

UPDATE - Insert/update cache entry across all LocalCachedMap instances on map entry change + *

NONE - No synchronizations on map changes + * @return LocalCachedMapOptions instance + */ + LocalCachedMapOptions syncStrategy(SyncStrategy syncStrategy); + + /** + * Defines local cache eviction policy. + * + * @param evictionPolicy + *

LRU - uses local cache with LRU (least recently used) eviction policy. + *

LFU - uses local cache with LFU (least frequently used) eviction policy. + *

SOFT - uses local cache with soft references. The garbage collector will evict items from the local cache when the JVM is running out of memory. + *

WEAK - uses local cache with weak references. The garbage collector will evict items from the local cache when it became weakly reachable. + *

NONE - doesn't use eviction policy, but timeToLive and maxIdleTime params are still working. + * @return LocalCachedMapOptions instance + */ + LocalCachedMapOptions evictionPolicy(EvictionPolicy evictionPolicy); + + /** + * Defines time to live in milliseconds of each map entry in local cache. + * If value equals to 0 then timeout is not applied + * + * @param ttl - time to live in milliseconds + * @return LocalCachedMapOptions instance + */ + LocalCachedMapOptions timeToLive(Duration ttl); + + /** + * Defines max idle time in milliseconds of each map entry in local cache. + * If value equals to 0 then timeout is not applied + * + * @param idleTime time to live in milliseconds + * @return LocalCachedMapOptions instance + */ + LocalCachedMapOptions maxIdle(Duration idleTime); + + /** + * Defines store mode of cache data. + * + * @param storeMode

LOCALCACHE - store data in local cache only. + *

LOCALCACHE_REDIS - store data in both Redis and local cache. + * @return LocalCachedMapOptions instance + */ + LocalCachedMapOptions storeMode(StoreMode storeMode); + + /** + * Defines Cache provider used as local cache store. + * + * @param cacheProvider

REDISSON - uses Redisson own implementation. + *

CAFFEINE - uses Caffeine implementation. + * @return LocalCachedMapOptions instance + */ + LocalCachedMapOptions cacheProvider(CacheProvider cacheProvider); + + /** + * Defines whether to store a cache miss into the local cache. + * + * @param storeCacheMiss - whether to store a cache miss into the local cache + * @return LocalCachedMapOptions instance + */ + LocalCachedMapOptions storeCacheMiss(boolean storeCacheMiss); + + /** + * Defines whether to use __keyevent pattern topic to listen for expired events. + * + * @param useKeyEventsPattern - whether to use __keyevent pattern topic + * @return LocalCachedMapOptions instance + */ + LocalCachedMapOptions useKeyEventsPattern(boolean useKeyEventsPattern); + +} diff --git a/redisson/src/main/java/org/redisson/api/options/LocalCachedMapParams.java b/redisson/src/main/java/org/redisson/api/options/LocalCachedMapParams.java new file mode 100644 index 000000000..f2c947167 --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/LocalCachedMapParams.java @@ -0,0 +1,231 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +import java.time.Duration; + +/** + * Configuration for LocalCachedMap object. + * + * @author Nikita Koksharov + * + * @param key type + * @param value type + */ +public final class LocalCachedMapParams extends BaseMapOptions, K, V> implements LocalCachedMapOptions { + + private final String name; + private ReconnectionStrategy reconnectionStrategy = ReconnectionStrategy.NONE; + private SyncStrategy syncStrategy = SyncStrategy.INVALIDATE; + private EvictionPolicy evictionPolicy = EvictionPolicy.NONE; + private int cacheSize; + private long timeToLiveInMillis; + private long maxIdleInMillis; + private CacheProvider cacheProvider = CacheProvider.REDISSON; + private StoreMode storeMode = StoreMode.LOCALCACHE_REDIS; + private boolean storeCacheMiss; + private boolean useKeyEventsPattern = true; + + LocalCachedMapParams(String name) { + this.name = name; + } + + public CacheProvider getCacheProvider() { + return cacheProvider; + } + + public EvictionPolicy getEvictionPolicy() { + return evictionPolicy; + } + + public int getCacheSize() { + return cacheSize; + } + + public long getTimeToLiveInMillis() { + return timeToLiveInMillis; + } + + public long getMaxIdleInMillis() { + return maxIdleInMillis; + } + + /** + * Defines local cache size. + *

+ * If size is 0 then local cache is unbounded. + *

+ * If size is -1 then local cache is always empty and doesn't store data. + * + * @param cacheSize size of cache + * @return LocalCachedMapOptions instance + */ + public LocalCachedMapParams cacheSize(int cacheSize) { + this.cacheSize = cacheSize; + return this; + } + + public ReconnectionStrategy getReconnectionStrategy() { + return reconnectionStrategy; + } + + public SyncStrategy getSyncStrategy() { + return syncStrategy; + } + + /** + * Defines strategy for load missed local cache updates after Redis connection failure. + * + * @param reconnectionStrategy + *

CLEAR - clear local cache if map instance has been disconnected for a while. + *

LOAD - store invalidated entry hash in invalidation log for 10 minutes. Cache keys for stored invalidated entry hashes will be removed if LocalCachedMap instance has been disconnected less than 10 minutes or whole cache will be cleaned otherwise + *

NONE - Default. No reconnection handling + * @return LocalCachedMapOptions instance + */ + public LocalCachedMapParams reconnectionStrategy(ReconnectionStrategy reconnectionStrategy) { + if (reconnectionStrategy == null) { + throw new NullPointerException("reconnectionStrategy can't be null"); + } + + this.reconnectionStrategy = reconnectionStrategy; + return this; + } + + /** + * Defines local cache synchronization strategy. + * + * @param syncStrategy + *

INVALIDATE - Default. Invalidate cache entry across all LocalCachedMap instances on map entry change + *

UPDATE - Insert/update cache entry across all LocalCachedMap instances on map entry change + *

NONE - No synchronizations on map changes + * @return LocalCachedMapOptions instance + */ + public LocalCachedMapParams syncStrategy(SyncStrategy syncStrategy) { + if (syncStrategy == null) { + throw new NullPointerException("syncStrategy can't be null"); + } + + this.syncStrategy = syncStrategy; + return this; + } + + /** + * Defines local cache eviction policy. + * + * @param evictionPolicy + *

LRU - uses local cache with LRU (least recently used) eviction policy. + *

LFU - uses local cache with LFU (least frequently used) eviction policy. + *

SOFT - uses local cache with soft references. The garbage collector will evict items from the local cache when the JVM is running out of memory. + *

WEAK - uses local cache with weak references. The garbage collector will evict items from the local cache when it became weakly reachable. + *

NONE - doesn't use eviction policy, but timeToLive and maxIdleTime params are still working. + * @return LocalCachedMapOptions instance + */ + public LocalCachedMapParams evictionPolicy(EvictionPolicy evictionPolicy) { + if (evictionPolicy == null) { + throw new NullPointerException("evictionPolicy can't be null"); + } + this.evictionPolicy = evictionPolicy; + return this; + } + + /** + * Defines time to live in milliseconds of each map entry in local cache. + * If value equals to 0 then timeout is not applied + * + * @param ttl time to live in milliseconds + * @return LocalCachedMapOptions instance + */ + public LocalCachedMapParams timeToLive(Duration ttl) { + this.timeToLiveInMillis = ttl.toMillis(); + return this; + } + + /** + * Defines max idle time in milliseconds of each map entry in local cache. + * If value equals to 0 then timeout is not applied + * + * @param idleTime time to live in milliseconds + * @return LocalCachedMapOptions instance + */ + public LocalCachedMapParams maxIdle(Duration idleTime) { + this.maxIdleInMillis = idleTime.toMillis(); + return this; + } + + public StoreMode getStoreMode() { + return storeMode; + } + + /** + * Defines store mode of cache data. + * + * @param storeMode + *

LOCALCACHE - store data in local cache only. + *

LOCALCACHE_REDIS - store data in both Redis and local cache. + * @return LocalCachedMapOptions instance + */ + public LocalCachedMapParams storeMode(StoreMode storeMode) { + this.storeMode = storeMode; + return this; + } + + /** + * Defines Cache provider used as local cache store. + * + * @param cacheProvider + *

REDISSON - uses Redisson own implementation. + *

CAFFEINE - uses Caffeine implementation. + * @return LocalCachedMapOptions instance + */ + public LocalCachedMapParams cacheProvider(CacheProvider cacheProvider) { + this.cacheProvider = cacheProvider; + return this; + } + + public boolean isStoreCacheMiss() { + return this.storeCacheMiss; + } + + /** + * Defines whether to store a cache miss into the local cache. + * + * @param storeCacheMiss - whether to store a cache miss into the local cache + * @return LocalCachedMapOptions instance + */ + public LocalCachedMapParams storeCacheMiss(boolean storeCacheMiss) { + this.storeCacheMiss = storeCacheMiss; + return this; + } + + public boolean isUseKeyEventsPattern() { + return useKeyEventsPattern; + } + + /** + * Defines whether to use __keyevent pattern topic to listen for expired events. + * + * @param useKeyEventsPattern - whether to use __keyevent pattern topic + * @return LocalCachedMapOptions instance + */ + public LocalCachedMapParams useKeyEventsPattern(boolean useKeyEventsPattern) { + this.useKeyEventsPattern = useKeyEventsPattern; + return this; + } + + public String getName() { + return name; + } +} diff --git a/redisson/src/main/java/org/redisson/api/options/MapCacheOptions.java b/redisson/src/main/java/org/redisson/api/options/MapCacheOptions.java new file mode 100644 index 000000000..52b414cfc --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/MapCacheOptions.java @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +/** + * {@link org.redisson.api.RMapCache} instance options. + * + * @author Nikita Koksharov + * + * @param type of key + * @param type of value + */ +public interface MapCacheOptions extends ExMapOptions, K, V> { + + /** + * Creates options with the name of object instance + * + * @param name of object instance + * @return options instance + */ + static MapCacheOptions name(String name) { + return new MapCacheParams<>(name); + } + + /** + * Removes eviction task from memory if map is empty + * upon entries eviction process completion. + * + * @return MapCacheOptions instance + */ + MapCacheOptions removeEmptyEvictionTask(); + + +} diff --git a/redisson/src/main/java/org/redisson/api/options/MapCacheParams.java b/redisson/src/main/java/org/redisson/api/options/MapCacheParams.java new file mode 100644 index 000000000..8aee85972 --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/MapCacheParams.java @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +/** + * + * @author Nikita Koksharov + * + * @param type of key + * @param type of value + */ +public final class MapCacheParams extends BaseMapOptions, K, V> implements MapCacheOptions { + + private final String name; + private boolean removeEmptyEvictionTask; + + MapCacheParams(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + @Override + public MapCacheOptions removeEmptyEvictionTask() { + removeEmptyEvictionTask = true; + return this; + } + + public boolean isRemoveEmptyEvictionTask() { + return removeEmptyEvictionTask; + } +} diff --git a/redisson/src/main/java/org/redisson/api/options/MapOptions.java b/redisson/src/main/java/org/redisson/api/options/MapOptions.java new file mode 100644 index 000000000..bff73a1e5 --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/MapOptions.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +/** + * {@link org.redisson.api.RMap} instance options. + * + * @author Nikita Koksharov + * + * @param + * @param + */ +public interface MapOptions extends ExMapOptions, K, V> { + + /** + * Creates options with the name of object instance + * + * @param name of object instance + * @return options instance + */ + static MapOptions name(String name) { + return new MapParams<>(name); + } + +} diff --git a/redisson/src/main/java/org/redisson/api/options/MapParams.java b/redisson/src/main/java/org/redisson/api/options/MapParams.java new file mode 100644 index 000000000..3550c2b79 --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/MapParams.java @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +/** + * + * @author Nikita Koksharov + * + * @param + * @param + */ +public final class MapParams extends BaseMapOptions, K, V> implements MapOptions { + + private final String name; + + MapParams(String name) { + this.name = name; + } + + public String getName() { + return name; + } + +} diff --git a/redisson/src/main/java/org/redisson/api/options/ObjectParams.java b/redisson/src/main/java/org/redisson/api/options/ObjectParams.java new file mode 100644 index 000000000..ee94e5383 --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/ObjectParams.java @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +/** + * + * @author Nikita Koksharov + * + */ +public interface ObjectParams { + + int getTimeout(); + + int getRetryAttempts(); + + int getRetryInterval(); + + +} diff --git a/redisson/src/main/java/org/redisson/api/options/OptionalOptions.java b/redisson/src/main/java/org/redisson/api/options/OptionalOptions.java new file mode 100644 index 000000000..4b02badda --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/OptionalOptions.java @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +import org.redisson.client.codec.Codec; + +/** + * Object instances options + * + * @author Nikita Koksharov + * + */ +public interface OptionalOptions extends CodecOptions { + + /** + * Creates the default options + * + * @return options instance + */ + static OptionalOptions defaults() { + return new OptionalParams(); + } + +} diff --git a/redisson/src/main/java/org/redisson/api/options/OptionalParams.java b/redisson/src/main/java/org/redisson/api/options/OptionalParams.java new file mode 100644 index 000000000..221b358ad --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/OptionalParams.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +import org.redisson.client.codec.Codec; + +/** + * + * @author Nikita Koksharov + * + */ +public final class OptionalParams extends BaseOptions implements OptionalOptions { + + OptionalParams() { + } + +} diff --git a/redisson/src/main/java/org/redisson/api/options/PatternTopicOptions.java b/redisson/src/main/java/org/redisson/api/options/PatternTopicOptions.java new file mode 100644 index 000000000..a9be0421e --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/PatternTopicOptions.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +import org.redisson.client.codec.Codec; + +/** + * {@link org.redisson.api.RPatternTopic} instance options. + * + * @author Nikita Koksharov + * + */ +public interface PatternTopicOptions extends CodecOptions { + + /** + * Creates options with the pattern of object instance + * + * @param pattern of object instance + * @return options instance + */ + static PatternTopicOptions pattern(String pattern) { + return new PatternTopicParams(pattern); + } + +} diff --git a/redisson/src/main/java/org/redisson/api/options/PatternTopicParams.java b/redisson/src/main/java/org/redisson/api/options/PatternTopicParams.java new file mode 100644 index 000000000..b1ebc454d --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/PatternTopicParams.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +import org.redisson.client.codec.Codec; + +/** + * + * @author Nikita Koksharov + * + */ +public final class PatternTopicParams extends BaseOptions implements PatternTopicOptions { + + private final String pattern; + + PatternTopicParams(String pattern) { + this.pattern = pattern; + } + + public String getPattern() { + return pattern; + } +} diff --git a/redisson/src/main/java/org/redisson/api/options/PlainOptions.java b/redisson/src/main/java/org/redisson/api/options/PlainOptions.java new file mode 100644 index 000000000..bce88f402 --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/PlainOptions.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +import org.redisson.client.codec.Codec; + +/** + * Object instance options. + * + * @author Nikita Koksharov + * + */ +public interface PlainOptions extends CodecOptions { + + /** + * Creates options with the name of object instance + * + * @param name of object instance + * @return options instance + */ + static PlainOptions name(String name) { + return new PlainParams(name); + } + +} diff --git a/redisson/src/main/java/org/redisson/api/options/PlainParams.java b/redisson/src/main/java/org/redisson/api/options/PlainParams.java new file mode 100644 index 000000000..295c3f83b --- /dev/null +++ b/redisson/src/main/java/org/redisson/api/options/PlainParams.java @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.api.options; + +import org.redisson.client.codec.Codec; + +/** + * + * @author Nikita Koksharov + * + */ +public final class PlainParams extends BaseOptions implements PlainOptions { + + private final String name; + + PlainParams(String name) { + this.name = name; + } + + public String getName() { + return name; + } + +} diff --git a/redisson/src/main/java/org/redisson/command/BaseRedisBatchExecutor.java b/redisson/src/main/java/org/redisson/command/BaseRedisBatchExecutor.java index fac45bc7b..0a865abe1 100644 --- a/redisson/src/main/java/org/redisson/command/BaseRedisBatchExecutor.java +++ b/redisson/src/main/java/org/redisson/command/BaseRedisBatchExecutor.java @@ -53,24 +53,37 @@ public class BaseRedisBatchExecutor extends RedisExecutor { boolean noRetry) { super(readOnlyMode, source, codec, command, params, mainPromise, ignoreRedirect, connectionManager, - objectBuilder, referenceType, noRetry); + objectBuilder, referenceType, noRetry, + retryAttempts(connectionManager, options), retryInterval(connectionManager, options), timeout(connectionManager, options)); this.commands = commands; this.options = options; this.index = index; this.executed = executed; + } - if (options.getRetryAttempts() >= 0) { - this.attempts = options.getRetryAttempts(); - } - if (options.getRetryInterval() > 0) { - this.retryInterval = options.getRetryInterval(); - } + private static int timeout(ConnectionManager connectionManager, BatchOptions options) { + int result = connectionManager.getServiceManager().getConfig().getTimeout(); if (options.getResponseTimeout() > 0) { - this.responseTimeout = options.getResponseTimeout(); + result = (int) options.getResponseTimeout(); } if (options.getSyncSlaves() > 0) { - this.responseTimeout += options.getSyncTimeout(); + result += options.getSyncTimeout(); + } + return result; + } + + private static int retryInterval(ConnectionManager connectionManager, BatchOptions options) { + if (options.getRetryInterval() > 0) { + return (int) options.getRetryInterval(); + } + return connectionManager.getServiceManager().getConfig().getRetryInterval(); + } + + private static int retryAttempts(ConnectionManager connectionManager, BatchOptions options) { + if (options.getRetryAttempts() >= 0) { + return options.getRetryAttempts(); } + return connectionManager.getServiceManager().getConfig().getRetryAttempts(); } protected final void addBatchCommandData(Object[] batchParams) { diff --git a/redisson/src/main/java/org/redisson/command/CommandAsyncService.java b/redisson/src/main/java/org/redisson/command/CommandAsyncService.java index ff99df779..9450f32ef 100644 --- a/redisson/src/main/java/org/redisson/command/CommandAsyncService.java +++ b/redisson/src/main/java/org/redisson/command/CommandAsyncService.java @@ -24,6 +24,7 @@ import org.redisson.api.BatchOptions; import org.redisson.api.BatchResult; import org.redisson.api.NodeType; import org.redisson.api.RFuture; +import org.redisson.api.options.ObjectParams; import org.redisson.client.RedisClient; import org.redisson.client.RedisException; import org.redisson.client.codec.Codec; @@ -63,12 +64,44 @@ public class CommandAsyncService implements CommandAsyncExecutor { final ConnectionManager connectionManager; final RedissonObjectBuilder objectBuilder; final RedissonObjectBuilder.ReferenceType referenceType; + private final int retryAttempts; + private final int retryInterval; + private final int responseTimeout; + + public CommandAsyncService(CommandAsyncExecutor executor, + ObjectParams objectParams) { + CommandAsyncService service = (CommandAsyncService) executor; + this.codec = service.codec; + this.connectionManager = service.connectionManager; + this.objectBuilder = service.objectBuilder; + this.referenceType = service.referenceType; + + if (objectParams.getRetryAttempts() >= 0) { + this.retryAttempts = objectParams.getRetryAttempts(); + } else { + this.retryAttempts = connectionManager.getServiceManager().getConfig().getRetryAttempts(); + } + if (objectParams.getRetryInterval() > 0) { + this.retryInterval = objectParams.getRetryInterval(); + } else { + this.retryInterval = connectionManager.getServiceManager().getConfig().getRetryInterval(); + } + if (objectParams.getTimeout() > 0) { + this.responseTimeout = objectParams.getTimeout(); + } else { + this.responseTimeout = connectionManager.getServiceManager().getConfig().getTimeout(); + } + } - public CommandAsyncService(ConnectionManager connectionManager, RedissonObjectBuilder objectBuilder, RedissonObjectBuilder.ReferenceType referenceType) { + public CommandAsyncService(ConnectionManager connectionManager, RedissonObjectBuilder objectBuilder, + RedissonObjectBuilder.ReferenceType referenceType) { this.connectionManager = connectionManager; this.objectBuilder = objectBuilder; this.referenceType = referenceType; this.codec = connectionManager.getServiceManager().getCfg().getCodec(); + this.retryAttempts = connectionManager.getServiceManager().getConfig().getRetryAttempts(); + this.retryInterval = connectionManager.getServiceManager().getConfig().getRetryInterval(); + this.responseTimeout = connectionManager.getServiceManager().getConfig().getTimeout(); } @Override @@ -459,7 +492,8 @@ public class CommandAsyncService implements CommandAsyncExecutor { RedisExecutor executor = new RedisExecutor<>(readOnlyMode, nodeSource, codec, cmd, args.toArray(), promise, false, - connectionManager, objectBuilder, referenceType, noRetry); + connectionManager, objectBuilder, referenceType, noRetry, + retryAttempts, retryInterval, responseTimeout); executor.execute(); promise.whenComplete((res, e) -> { @@ -543,7 +577,8 @@ public class CommandAsyncService implements CommandAsyncExecutor { RedisCommand cmd = new RedisCommand("SORT_RO", command.getReplayMultiDecoder()); CompletableFuture mainPromise = createPromise(); RedisExecutor executor = new RedisExecutor<>(readOnlyMode, source, codec, cmd, params, mainPromise, - ignoreRedirect, connectionManager, objectBuilder, referenceType, noRetry); + ignoreRedirect, connectionManager, objectBuilder, referenceType, noRetry, + retryAttempts, retryInterval, responseTimeout); executor.execute(); CompletableFuture result = new CompletableFuture<>(); mainPromise.whenComplete((r, e) -> { @@ -560,7 +595,8 @@ public class CommandAsyncService implements CommandAsyncExecutor { CompletableFuture mainPromise = createPromise(); RedisExecutor executor = new RedisExecutor<>(readOnlyMode, source, codec, command, params, mainPromise, - ignoreRedirect, connectionManager, objectBuilder, referenceType, noRetry); + ignoreRedirect, connectionManager, objectBuilder, referenceType, noRetry, + retryAttempts, retryInterval, responseTimeout); executor.execute(); return new CompletableFutureWrapper<>(mainPromise); } diff --git a/redisson/src/main/java/org/redisson/command/RedisCommonBatchExecutor.java b/redisson/src/main/java/org/redisson/command/RedisCommonBatchExecutor.java index 354aeddd4..4e11bfc07 100644 --- a/redisson/src/main/java/org/redisson/command/RedisCommonBatchExecutor.java +++ b/redisson/src/main/java/org/redisson/command/RedisCommonBatchExecutor.java @@ -56,23 +56,36 @@ public class RedisCommonBatchExecutor extends RedisExecutor { ConnectionManager connectionManager, BatchOptions options, Entry entry, AtomicInteger slots, RedissonObjectBuilder.ReferenceType referenceType, boolean noRetry) { super(entry.isReadOnlyMode(), source, null, null, null, - mainPromise, false, connectionManager, null, referenceType, noRetry); + mainPromise, false, connectionManager, null, referenceType, noRetry, + retryAttempts(connectionManager, options), retryInterval(connectionManager, options), timeout(connectionManager, options)); this.options = options; this.entry = entry; this.slots = slots; - - if (options.getRetryAttempts() >= 0) { - this.attempts = options.getRetryAttempts(); - } - if (options.getRetryInterval() > 0) { - this.retryInterval = options.getRetryInterval(); - } + } + + private static int timeout(ConnectionManager connectionManager, BatchOptions options) { + int result = connectionManager.getServiceManager().getConfig().getTimeout(); if (options.getResponseTimeout() > 0) { - this.responseTimeout = options.getResponseTimeout(); + result = (int) options.getResponseTimeout(); } if (options.getSyncSlaves() > 0) { - this.responseTimeout += options.getSyncTimeout(); + result += options.getSyncTimeout(); + } + return result; + } + + private static int retryInterval(ConnectionManager connectionManager, BatchOptions options) { + if (options.getRetryInterval() > 0) { + return (int) options.getRetryInterval(); + } + return connectionManager.getServiceManager().getConfig().getRetryInterval(); + } + + private static int retryAttempts(ConnectionManager connectionManager, BatchOptions options) { + if (options.getRetryAttempts() >= 0) { + return options.getRetryAttempts(); } + return connectionManager.getServiceManager().getConfig().getRetryAttempts(); } @Override diff --git a/redisson/src/main/java/org/redisson/command/RedisExecutor.java b/redisson/src/main/java/org/redisson/command/RedisExecutor.java index 973e1539b..2b2b70c9a 100644 --- a/redisson/src/main/java/org/redisson/command/RedisExecutor.java +++ b/redisson/src/main/java/org/redisson/command/RedisExecutor.java @@ -73,6 +73,9 @@ public class RedisExecutor { final ConnectionManager connectionManager; final RedissonObjectBuilder.ReferenceType referenceType; final boolean noRetry; + final int attempts; + final int retryInterval; + final int responseTimeout; CompletableFuture connectionFuture; NodeSource source; @@ -84,14 +87,11 @@ public class RedisExecutor { volatile ChannelFuture writeFuture; volatile RedisException exception; - int attempts; - long retryInterval; - long responseTimeout; - public RedisExecutor(boolean readOnlyMode, NodeSource source, Codec codec, RedisCommand command, Object[] params, CompletableFuture mainPromise, boolean ignoreRedirect, ConnectionManager connectionManager, RedissonObjectBuilder objectBuilder, - RedissonObjectBuilder.ReferenceType referenceType, boolean noRetry) { + RedissonObjectBuilder.ReferenceType referenceType, boolean noRetry, + int retryAttempts, int retryInterval, int responseTimeout) { super(); this.readOnlyMode = readOnlyMode; this.source = source; @@ -104,9 +104,9 @@ public class RedisExecutor { this.objectBuilder = objectBuilder; this.noRetry = noRetry; - this.attempts = connectionManager.getServiceManager().getConfig().getRetryAttempts(); - this.retryInterval = connectionManager.getServiceManager().getConfig().getRetryInterval(); - this.responseTimeout = connectionManager.getServiceManager().getConfig().getTimeout(); + this.attempts = retryAttempts; + this.retryInterval = retryInterval; + this.responseTimeout = responseTimeout; this.referenceType = referenceType; } diff --git a/redisson/src/main/java/org/redisson/connection/ServiceManager.java b/redisson/src/main/java/org/redisson/connection/ServiceManager.java index 2a9280861..a0ef9548f 100644 --- a/redisson/src/main/java/org/redisson/connection/ServiceManager.java +++ b/redisson/src/main/java/org/redisson/connection/ServiceManager.java @@ -49,6 +49,7 @@ import org.redisson.api.RFuture; import org.redisson.api.StreamMessageId; import org.redisson.cache.LRUCacheMap; import org.redisson.client.RedisNodeNotFoundException; +import org.redisson.client.codec.Codec; import org.redisson.client.protocol.RedisCommand; import org.redisson.client.protocol.RedisCommands; import org.redisson.config.Config; @@ -599,4 +600,12 @@ public class ServiceManager { public QueueTransferService getQueueTransferService() { return queueTransferService; } + + public Codec getCodec(Codec codec) { + if (codec == null) { + return cfg.getCodec(); + } + return codec; + } + } diff --git a/redisson/src/main/java/org/redisson/reactive/CommandReactiveService.java b/redisson/src/main/java/org/redisson/reactive/CommandReactiveService.java index 2366fa87b..eac18a500 100644 --- a/redisson/src/main/java/org/redisson/reactive/CommandReactiveService.java +++ b/redisson/src/main/java/org/redisson/reactive/CommandReactiveService.java @@ -19,6 +19,8 @@ import java.util.concurrent.Callable; import java.util.concurrent.CompletionException; import org.redisson.api.RFuture; +import org.redisson.api.options.ObjectParams; +import org.redisson.command.CommandAsyncExecutor; import org.redisson.command.CommandAsyncService; import org.redisson.connection.ConnectionManager; import org.redisson.liveobject.core.RedissonObjectBuilder; @@ -36,6 +38,10 @@ public class CommandReactiveService extends CommandAsyncService implements Comma super(connectionManager, objectBuilder, RedissonObjectBuilder.ReferenceType.REACTIVE); } + public CommandReactiveService(CommandAsyncExecutor executor, ObjectParams objectParams) { + super(executor, objectParams); + } + @Override public Mono reactive(Callable> supplier) { return Flux.create(emitter -> { diff --git a/redisson/src/main/java/org/redisson/remote/BaseRemoteService.java b/redisson/src/main/java/org/redisson/remote/BaseRemoteService.java index b8c164869..b9478710e 100644 --- a/redisson/src/main/java/org/redisson/remote/BaseRemoteService.java +++ b/redisson/src/main/java/org/redisson/remote/BaseRemoteService.java @@ -67,7 +67,7 @@ public abstract class BaseRemoteService { protected final String responseQueueName; public BaseRemoteService(Codec codec, String name, CommandAsyncExecutor commandExecutor, String executorId) { - this.codec = codec; + this.codec = commandExecutor.getServiceManager().getCodec(codec); this.name = commandExecutor.getServiceManager().getConfig().getNameMapper().map(name); this.commandExecutor = commandExecutor; this.executorId = executorId; diff --git a/redisson/src/main/java/org/redisson/rx/CommandRxService.java b/redisson/src/main/java/org/redisson/rx/CommandRxService.java index 0db5ee4f9..31c54b358 100644 --- a/redisson/src/main/java/org/redisson/rx/CommandRxService.java +++ b/redisson/src/main/java/org/redisson/rx/CommandRxService.java @@ -20,6 +20,8 @@ import io.reactivex.rxjava3.functions.Action; import io.reactivex.rxjava3.functions.LongConsumer; import io.reactivex.rxjava3.processors.ReplayProcessor; import org.redisson.api.RFuture; +import org.redisson.api.options.ObjectParams; +import org.redisson.command.CommandAsyncExecutor; import org.redisson.command.CommandAsyncService; import org.redisson.connection.ConnectionManager; import org.redisson.liveobject.core.RedissonObjectBuilder; @@ -38,6 +40,10 @@ public class CommandRxService extends CommandAsyncService implements CommandRxEx super(connectionManager, objectBuilder, RedissonObjectBuilder.ReferenceType.RXJAVA); } + public CommandRxService(CommandAsyncExecutor executor, ObjectParams objectParams) { + super(executor, objectParams); + } + @Override public Flowable flowable(Callable> supplier) { ReplayProcessor p = ReplayProcessor.create(); diff --git a/redisson/src/test/java/org/redisson/RedissonBucketTest.java b/redisson/src/test/java/org/redisson/RedissonBucketTest.java index f5f64aa90..5c29bb404 100755 --- a/redisson/src/test/java/org/redisson/RedissonBucketTest.java +++ b/redisson/src/test/java/org/redisson/RedissonBucketTest.java @@ -1,7 +1,6 @@ package org.redisson; import net.bytebuddy.utility.RandomString; -import org.awaitility.Awaitility; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.redisson.RedisRunner.FailedToStartRedisException; @@ -10,6 +9,8 @@ import org.redisson.api.ExpiredObjectListener; import org.redisson.api.RBucket; import org.redisson.api.RedissonClient; import org.redisson.api.listener.SetObjectListener; +import org.redisson.api.options.PlainOptions; +import org.redisson.client.RedisResponseTimeoutException; import org.redisson.config.Config; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.Network; @@ -20,7 +21,6 @@ import java.time.Instant; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Map; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.function.BiConsumer; @@ -29,6 +29,26 @@ import static org.assertj.core.api.Assertions.assertThat; public class RedissonBucketTest extends RedisDockerTest { + @Test + public void testOptions() { + Config c = createConfig(); + c.useSingleServer().setTimeout(10); + + RedissonClient r = Redisson.create(c); + + String val = RandomString.make(1048 * 10000); + Assertions.assertThrows(RedisResponseTimeoutException.class, () -> { + RBucket al = r.getBucket("test"); + al.set(val); + }); + + RBucket al = r.getBucket(PlainOptions.name("test") + .timeout(Duration.ofSeconds(1))); + al.set(val); + + r.shutdown(); + } + @Test public void testGetAndClearExpire() { RBucket al = redisson.getBucket("test");