Feature - ability to specify retryInterval, retryAttempts, timeout parameters per Redisson object. #5316

pull/5540/head
Nikita Koksharov 1 year ago
parent 20ecfb3594
commit db2f746aed

@ -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 <V, L> RTimeSeries<V, L> getTimeSeries(PlainOptions options) {
PlainParams params = (PlainParams) options;
return new RedissonTimeSeries<>(params.getCodec(), evictionScheduler,
new CommandAsyncService(commandExecutor, params),
params.getName());
}
@Override
public <K, V> RStream<K, V> getStream(String name) {
return new RedissonStream<K, V>(commandExecutor, name);
@ -173,7 +187,13 @@ public final class Redisson implements RedissonClient {
@Override
public <K, V> RStream<K, V> getStream(String name, Codec codec) {
return new RedissonStream<K, V>(codec, commandExecutor, name);
return new RedissonStream<>(codec, commandExecutor, name);
}
@Override
public <K, V> RStream<K, V> 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 <V> RGeo<V> getGeo(String name) {
return new RedissonGeo<V>(commandExecutor, name, this);
@ -201,6 +233,13 @@ public final class Redisson implements RedissonClient {
return new RedissonGeo<V>(codec, commandExecutor, name, this);
}
@Override
public <V> RGeo<V> getGeo(PlainOptions options) {
PlainParams params = (PlainParams) options;
return new RedissonGeo<>(params.getCodec(), new CommandAsyncService(commandExecutor, params),
params.getName(), this);
}
@Override
public <V> RBucket<V> getBucket(String name) {
return new RedissonBucket<V>(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 <V> RBucket<V> getBucket(String name, Codec codec) {
return new RedissonBucket<V>(codec, commandExecutor, name);
return new RedissonBucket<>(codec, commandExecutor, name);
}
@Override
public <V> RBucket<V> 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 <V> RJsonBucket<V> getJsonBucket(String name, JsonCodec<V> codec) {
return new RedissonJsonBucket<>(codec, commandExecutor, name);
}
@Override
public <V> RJsonBucket<V> getJsonBucket(JsonBucketOptions<V> options) {
JsonBucketParams<V> params = (JsonBucketParams) options;
return new RedissonJsonBucket<>(params.getCodec(), commandExecutor, params.getName());
}
@Override
public <V> RHyperLogLog<V> getHyperLogLog(String name) {
return new RedissonHyperLogLog<V>(commandExecutor, name);
@ -241,6 +304,12 @@ public final class Redisson implements RedissonClient {
return new RedissonHyperLogLog<V>(codec, commandExecutor, name);
}
@Override
public <V> RHyperLogLog<V> getHyperLogLog(PlainOptions options) {
PlainParams params = (PlainParams) options;
return new RedissonHyperLogLog<V>(params.getCodec(), new CommandAsyncService(commandExecutor, params), params.getName());
}
@Override
public <V> RList<V> getList(String name) {
return new RedissonList<V>(commandExecutor, name, this);
@ -251,6 +320,12 @@ public final class Redisson implements RedissonClient {
return new RedissonList<V>(codec, commandExecutor, name, this);
}
@Override
public <V> RList<V> getList(PlainOptions options) {
PlainParams params = (PlainParams) options;
return new RedissonList<V>(params.getCodec(), new CommandAsyncService(commandExecutor, params), params.getName(), this);
}
@Override
public <K, V> RListMultimap<K, V> getListMultimap(String name) {
return new RedissonListMultimap<K, V>(commandExecutor, name);
@ -261,6 +336,12 @@ public final class Redisson implements RedissonClient {
return new RedissonListMultimap<K, V>(codec, commandExecutor, name);
}
@Override
public <K, V> RListMultimap<K, V> getListMultimap(PlainOptions options) {
PlainParams params = (PlainParams) options;
return new RedissonListMultimap<>(params.getCodec(), new CommandAsyncService(commandExecutor, params), params.getName());
}
@Override
public <K, V> RLocalCachedMap<K, V> getLocalCachedMap(String name, LocalCachedMapOptions<K, V> options) {
return new RedissonLocalCachedMap<K, V>(commandExecutor, name,
@ -273,6 +354,35 @@ public final class Redisson implements RedissonClient {
options, evictionScheduler, this, writeBehindService);
}
@Override
public <K, V> RLocalCachedMap<K, V> getLocalCachedMap(org.redisson.api.options.LocalCachedMapOptions<K, V> options) {
LocalCachedMapParams<K, V> params = (LocalCachedMapParams) options;
LocalCachedMapOptions<K, V> ops = LocalCachedMapOptions.<K, V>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 <K, V> RMap<K, V> getMap(String name) {
return new RedissonMap<K, V>(commandExecutor, name, this, null, null);
@ -283,6 +393,24 @@ public final class Redisson implements RedissonClient {
return new RedissonMap<K, V>(commandExecutor, name, this, options, writeBehindService);
}
@Override
public <K, V> RMap<K, V> getMap(org.redisson.api.options.MapOptions<K, V> options) {
MapParams<K, V> params = (MapParams<K, V>) options;
MapOptions<K, V> ops = MapOptions.<K, V>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 <K, V> RSetMultimap<K, V> getSetMultimap(String name) {
return new RedissonSetMultimap<K, V>(commandExecutor, name);
@ -298,6 +426,13 @@ public final class Redisson implements RedissonClient {
return new RedissonSetMultimapCache<K, V>(evictionScheduler, codec, commandExecutor, name);
}
@Override
public <K, V> RSetMultimapCache<K, V> getSetMultimapCache(PlainOptions options) {
PlainParams params = (PlainParams) options;
return new RedissonSetMultimapCache<K, V>(evictionScheduler, params.getCodec(),
new CommandAsyncService(commandExecutor, params), params.getName());
}
@Override
public <K, V> RListMultimapCache<K, V> getListMultimapCache(String name) {
return new RedissonListMultimapCache<K, V>(evictionScheduler, commandExecutor, name);
@ -308,11 +443,24 @@ public final class Redisson implements RedissonClient {
return new RedissonListMultimapCache<K, V>(evictionScheduler, codec, commandExecutor, name);
}
@Override
public <K, V> RListMultimapCache<K, V> getListMultimapCache(PlainOptions options) {
PlainParams params = (PlainParams) options;
return new RedissonListMultimapCache<K, V>(evictionScheduler, params.getCodec(),
new CommandAsyncService(commandExecutor, params), params.getName());
}
@Override
public <K, V> RSetMultimap<K, V> getSetMultimap(String name, Codec codec) {
return new RedissonSetMultimap<K, V>(codec, commandExecutor, name);
}
@Override
public <K, V> RSetMultimap<K, V> getSetMultimap(PlainOptions options) {
PlainParams params = (PlainParams) options;
return new RedissonSetMultimap<>(params.getCodec(), new CommandAsyncService(commandExecutor, params), params.getName());
}
@Override
public <V> RSetCache<V> getSetCache(String name) {
return new RedissonSetCache<V>(evictionScheduler, commandExecutor, name, this);
@ -323,6 +471,13 @@ public final class Redisson implements RedissonClient {
return new RedissonSetCache<V>(codec, evictionScheduler, commandExecutor, name, this);
}
@Override
public <V> RSetCache<V> getSetCache(PlainOptions options) {
PlainParams params = (PlainParams) options;
return new RedissonSetCache<V>(params.getCodec(), evictionScheduler,
new CommandAsyncService(commandExecutor, params), params.getName(), this);
}
@Override
public <K, V> RMapCache<K, V> getMapCache(String name) {
return new RedissonMapCache<K, V>(evictionScheduler, commandExecutor, name, this, null, null);
@ -343,6 +498,27 @@ public final class Redisson implements RedissonClient {
return new RedissonMapCache<K, V>(codec, evictionScheduler, commandExecutor, name, this, options, writeBehindService);
}
@Override
public <K, V> RMapCache<K, V> getMapCache(org.redisson.api.options.MapCacheOptions<K, V> options) {
MapCacheParams<K, V> params = (MapCacheParams<K, V>) options;
MapCacheOptions<K, V> ops = MapCacheOptions.<K, V>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 <K, V> RMap<K, V> getMap(String name, Codec codec) {
return new RedissonMap<K, V>(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 <V> RSet<V> getSet(String name) {
return new RedissonSet<V>(commandExecutor, name, this);
@ -403,6 +603,12 @@ public final class Redisson implements RedissonClient {
return new RedissonSet<V>(codec, commandExecutor, name, this);
}
@Override
public <V> RSet<V> getSet(PlainOptions options) {
PlainParams params = (PlainParams) options;
return new RedissonSet<V>(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 <V> RSortedSet<V> getSortedSet(String name) {
return new RedissonSortedSet<V>(commandExecutor, name, this);
@ -477,6 +716,13 @@ public final class Redisson implements RedissonClient {
return new RedissonSortedSet<V>(codec, commandExecutor, name, this);
}
@Override
public <V> RSortedSet<V> getSortedSet(PlainOptions options) {
PlainParams params = (PlainParams) options;
return new RedissonSortedSet<V>(params.getCodec(),
new CommandAsyncService(commandExecutor, params), params.getName(), this);
}
@Override
public <V> RScoredSortedSet<V> getScoredSortedSet(String name) {
return new RedissonScoredSortedSet<V>(commandExecutor, name, this);
@ -487,11 +733,24 @@ public final class Redisson implements RedissonClient {
return new RedissonScoredSortedSet<V>(codec, commandExecutor, name, this);
}
@Override
public <V> RScoredSortedSet<V> getScoredSortedSet(PlainOptions options) {
PlainParams params = (PlainParams) options;
return new RedissonScoredSortedSet<V>(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 <V> RDelayedQueue<V> getDelayedQueue(RQueue<V> destinationQueue) {
if (destinationQueue == null) {
@ -550,6 +834,13 @@ public final class Redisson implements RedissonClient {
return new RedissonQueue<V>(codec, commandExecutor, name, this);
}
@Override
public <V> RQueue<V> getQueue(PlainOptions options) {
PlainParams params = (PlainParams) options;
return new RedissonQueue<V>(params.getCodec(),
new CommandAsyncService(commandExecutor, params), params.getName(), this);
}
@Override
public <V> RTransferQueue<V> getTransferQueue(String name) {
String remoteName = RedissonObject.suffixName(name, "remoteService");
@ -564,6 +855,15 @@ public final class Redisson implements RedissonClient {
return new RedissonTransferQueue<V>(codec, commandExecutor, name, service);
}
@Override
public <V> RTransferQueue<V> getTransferQueue(PlainOptions options) {
PlainParams params = (PlainParams) options;
String remoteName = RedissonObject.suffixName(params.getName(), "remoteService");
RRemoteService service = getRemoteService(remoteName);
return new RedissonTransferQueue<V>(params.getCodec(),
new CommandAsyncService(commandExecutor, params), params.getName(), service);
}
@Override
public <V> RRingBuffer<V> getRingBuffer(String name) {
return new RedissonRingBuffer<V>(commandExecutor, name, this);
@ -573,7 +873,14 @@ public final class Redisson implements RedissonClient {
public <V> RRingBuffer<V> getRingBuffer(String name, Codec codec) {
return new RedissonRingBuffer<V>(codec, commandExecutor, name, this);
}
@Override
public <V> RRingBuffer<V> getRingBuffer(PlainOptions options) {
PlainParams params = (PlainParams) options;
return new RedissonRingBuffer<V>(params.getCodec(),
new CommandAsyncService(commandExecutor, params), params.getName(), this);
}
@Override
public <V> RBlockingQueue<V> getBlockingQueue(String name) {
return new RedissonBlockingQueue<V>(commandExecutor, name, this);
@ -584,6 +891,13 @@ public final class Redisson implements RedissonClient {
return new RedissonBlockingQueue<V>(codec, commandExecutor, name, this);
}
@Override
public <V> RBlockingQueue<V> getBlockingQueue(PlainOptions options) {
PlainParams params = (PlainParams) options;
return new RedissonBlockingQueue<V>(params.getCodec(),
new CommandAsyncService(commandExecutor, params), params.getName(), this);
}
@Override
public <V> RBoundedBlockingQueue<V> getBoundedBlockingQueue(String name) {
return new RedissonBoundedBlockingQueue<V>(commandExecutor, name, this);
@ -594,6 +908,13 @@ public final class Redisson implements RedissonClient {
return new RedissonBoundedBlockingQueue<V>(codec, commandExecutor, name, this);
}
@Override
public <V> RBoundedBlockingQueue<V> getBoundedBlockingQueue(PlainOptions options) {
PlainParams params = (PlainParams) options;
return new RedissonBoundedBlockingQueue<V>(params.getCodec(),
new CommandAsyncService(commandExecutor, params), params.getName(), this);
}
@Override
public <V> RDeque<V> getDeque(String name) {
return new RedissonDeque<V>(commandExecutor, name, this);
@ -604,6 +925,13 @@ public final class Redisson implements RedissonClient {
return new RedissonDeque<V>(codec, commandExecutor, name, this);
}
@Override
public <V> RDeque<V> getDeque(PlainOptions options) {
PlainParams params = (PlainParams) options;
return new RedissonDeque<V>(params.getCodec(),
new CommandAsyncService(commandExecutor, params), params.getName(), this);
}
@Override
public <V> RBlockingDeque<V> getBlockingDeque(String name) {
return new RedissonBlockingDeque<V>(commandExecutor, name, this);
@ -612,48 +940,103 @@ public final class Redisson implements RedissonClient {
@Override
public <V> RBlockingDeque<V> getBlockingDeque(String name, Codec codec) {
return new RedissonBlockingDeque<V>(codec, commandExecutor, name, this);
};
}
@Override
public <V> RBlockingDeque<V> getBlockingDeque(PlainOptions options) {
PlainParams params = (PlainParams) options;
return new RedissonBlockingDeque<V>(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 <V> RBloomFilter<V> getBloomFilter(String name) {
return new RedissonBloomFilter<V>(commandExecutor, name);
@ -664,16 +1047,34 @@ public final class Redisson implements RedissonClient {
return new RedissonBloomFilter<V>(codec, commandExecutor, name);
}
@Override
public <V> RBloomFilter<V> getBloomFilter(PlainOptions options) {
PlainParams params = (PlainParams) options;
return new RedissonBloomFilter<V>(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<V>(codec, commandExecutor, name, this);
}
@Override
public <V> RPriorityQueue<V> getPriorityQueue(PlainOptions options) {
PlainParams params = (PlainParams) options;
return new RedissonPriorityQueue<V>(params.getCodec(),
new CommandAsyncService(commandExecutor, params), params.getName(), this);
}
@Override
public <V> RPriorityBlockingQueue<V> getPriorityBlockingQueue(String name) {
return new RedissonPriorityBlockingQueue<V>(commandExecutor, name, this);
@ -784,6 +1198,13 @@ public final class Redisson implements RedissonClient {
return new RedissonPriorityBlockingQueue<V>(codec, commandExecutor, name, this);
}
@Override
public <V> RPriorityBlockingQueue<V> getPriorityBlockingQueue(PlainOptions options) {
PlainParams params = (PlainParams) options;
return new RedissonPriorityBlockingQueue<V>(params.getCodec(),
new CommandAsyncService(commandExecutor, params), params.getName(), this);
}
@Override
public <V> RPriorityBlockingDeque<V> getPriorityBlockingDeque(String name) {
return new RedissonPriorityBlockingDeque<V>(commandExecutor, name, this);
@ -794,6 +1215,12 @@ public final class Redisson implements RedissonClient {
return new RedissonPriorityBlockingDeque<V>(codec, commandExecutor, name, this);
}
@Override
public <V> RPriorityBlockingDeque<V> getPriorityBlockingDeque(PlainOptions options) {
PlainParams params = (PlainParams) options;
return new RedissonPriorityBlockingDeque<V>(params.getCodec(),
new CommandAsyncService(commandExecutor, params), params.getName(), this);
}
@Override
public <V> RPriorityDeque<V> getPriorityDeque(String name) {
@ -805,6 +1232,13 @@ public final class Redisson implements RedissonClient {
return new RedissonPriorityDeque<V>(codec, commandExecutor, name, this);
}
@Override
public <V> RPriorityDeque<V> getPriorityDeque(PlainOptions options) {
PlainParams params = (PlainParams) options;
return new RedissonPriorityDeque<V>(params.getCodec(),
new CommandAsyncService(commandExecutor, params), params.getName(), this);
}
@Override
public String getId() {
return connectionManager.getServiceManager().getId();

@ -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;
}

@ -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;

@ -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

@ -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");

@ -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();
}

@ -47,13 +47,12 @@ public class RedissonPriorityBlockingDeque<V> extends RedissonPriorityDeque<V> i
protected RedissonPriorityBlockingDeque(CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson) {
super(commandExecutor, name, redisson);
blockingQueue = (RedissonPriorityBlockingQueue<V>) redisson.getPriorityBlockingQueue(name);
blockingQueue = new RedissonPriorityBlockingQueue<V>(commandExecutor, name, redisson);
}
protected RedissonPriorityBlockingDeque(Codec codec, CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson) {
super(codec, commandExecutor, name, redisson);
blockingQueue = (RedissonPriorityBlockingQueue<V>) redisson.getPriorityBlockingQueue(name, codec);
blockingQueue = new RedissonPriorityBlockingQueue<V>(codec, commandExecutor, name, redisson);
}
@Override

@ -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<K, V>(codec, commandExecutor, name), RStreamReactive.class);
}
@Override
public <K, V> RStreamReactive<K, V> getStream(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandAsyncService ca = new CommandAsyncService(commandExecutor, params);
return ReactiveProxyBuilder.create(commandExecutor,
new RedissonStream<K, V>(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 <V> RGeoReactive<V> getGeo(String name) {
return ReactiveProxyBuilder.create(commandExecutor, new RedissonGeo<V>(commandExecutor, name, null),
@ -111,17 +124,40 @@ public class RedissonReactive implements RedissonReactiveClient {
return ReactiveProxyBuilder.create(commandExecutor, new RedissonGeo<V>(codec, commandExecutor, name, null),
new RedissonScoredSortedSetReactive<V>(codec, commandExecutor, name), RGeoReactive.class);
}
@Override
public <V> RGeoReactive<V> getGeo(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandReactiveService ca = new CommandReactiveService(commandExecutor, params);
return ReactiveProxyBuilder.create(commandExecutor,
new RedissonGeo<V>(params.getCodec(), ca, params.getName(), null),
new RedissonScoredSortedSetReactive<V>(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 <K, V> RMapCacheReactive<K, V> getMapCache(String name, Codec codec) {
RMapCache<K, V> map = new RedissonMapCache<K, V>(codec, evictionScheduler, commandExecutor, name, null, null, null);
RMapCache<K, V> map = new RedissonMapCache<K, V>(codec, evictionScheduler, commandExecutor, name, null, null, writeBehindService);
return ReactiveProxyBuilder.create(commandExecutor, map,
new RedissonMapCacheReactive<K, V>(map, commandExecutor), RMapCacheReactive.class);
}
@Override
public <K, V> RMapCacheReactive<K, V> getMapCache(String name) {
RMapCache<K, V> map = new RedissonMapCache<K, V>(evictionScheduler, commandExecutor, name, null, null, null);
RMapCache<K, V> map = new RedissonMapCache<K, V>(evictionScheduler, commandExecutor, name, null, null, writeBehindService);
return ReactiveProxyBuilder.create(commandExecutor, map,
new RedissonMapCacheReactive<K, V>(map, commandExecutor), RMapCacheReactive.class);
}
@Override
public <K, V> RMapCacheReactive<K, V> getMapCache(org.redisson.api.options.MapCacheOptions<K, V> options) {
MapCacheParams<K, V> params = (MapCacheParams) options;
CommandReactiveService ca = new CommandReactiveService(commandExecutor, params);
RMapCache<K, V> map = new RedissonMapCache<>(params.getCodec(), evictionScheduler, ca,
params.getName(), null, null, writeBehindService);
return ReactiveProxyBuilder.create(commandExecutor, map,
new RedissonMapCacheReactive<K, V>(map, ca), RMapCacheReactive.class);
}
@Override
public <V> RBucketReactive<V> getBucket(String name) {
return ReactiveProxyBuilder.create(commandExecutor, new RedissonBucket<V>(commandExecutor, name), RBucketReactive.class);
@ -213,6 +312,14 @@ public class RedissonReactive implements RedissonReactiveClient {
return ReactiveProxyBuilder.create(commandExecutor, new RedissonBucket<V>(codec, commandExecutor, name), RBucketReactive.class);
}
@Override
public <V> RBucketReactive<V> getBucket(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandAsyncService ca = new CommandAsyncService(commandExecutor, params);
return ReactiveProxyBuilder.create(commandExecutor,
new RedissonBucket<V>(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 <V> List<RBucketReactive<V>> findBuckets(String pattern) {
RKeys redissonKeys = new RedissonKeys(commandExecutor);
@ -242,6 +356,14 @@ public class RedissonReactive implements RedissonReactiveClient {
return ReactiveProxyBuilder.create(commandExecutor, new RedissonJsonBucket<V>(codec, commandExecutor, name), RJsonBucketReactive.class);
}
@Override
public <V> RJsonBucketReactive<V> getJsonBucket(JsonBucketOptions<V> options) {
JsonBucketParams<V> params = (JsonBucketParams<V>) options;
CommandAsyncService ca = new CommandAsyncService(commandExecutor, params);
return ReactiveProxyBuilder.create(commandExecutor,
new RedissonJsonBucket<V>(params.getCodec(), ca, params.getName()), RJsonBucketReactive.class);
}
@Override
public <V> RHyperLogLogReactive<V> getHyperLogLog(String name) {
return ReactiveProxyBuilder.create(commandExecutor, new RedissonHyperLogLog<V>(commandExecutor, name), RHyperLogLogReactive.class);
@ -252,11 +374,26 @@ public class RedissonReactive implements RedissonReactiveClient {
return ReactiveProxyBuilder.create(commandExecutor, new RedissonHyperLogLog<V>(codec, commandExecutor, name), RHyperLogLogReactive.class);
}
@Override
public <V> RHyperLogLogReactive<V> getHyperLogLog(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandAsyncService ca = new CommandAsyncService(commandExecutor, params);
return ReactiveProxyBuilder.create(commandExecutor,
new RedissonHyperLogLog<V>(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 <V> RListReactive<V> getList(String name) {
return ReactiveProxyBuilder.create(commandExecutor, new RedissonList<V>(commandExecutor, name, null),
@ -269,6 +406,14 @@ public class RedissonReactive implements RedissonReactiveClient {
new RedissonListReactive<V>(codec, commandExecutor, name), RListReactive.class);
}
@Override
public <V> RListReactive<V> getList(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandReactiveService ca = new CommandReactiveService(commandExecutor, params);
return ReactiveProxyBuilder.create(commandExecutor, new RedissonList<V>(params.getCodec(), ca, params.getName(), null),
new RedissonListReactive<V>(params.getCodec(), ca, params.getName()), RListReactive.class);
}
@Override
public <K, V> RListMultimapReactive<K, V> getListMultimap(String name) {
return ReactiveProxyBuilder.create(commandExecutor, new RedissonListMultimap<K, V>(commandExecutor, name),
@ -281,6 +426,14 @@ public class RedissonReactive implements RedissonReactiveClient {
new RedissonListMultimapReactive<K, V>(codec, commandExecutor, name), RListMultimapReactive.class);
}
@Override
public <K, V> RListMultimapReactive<K, V> getListMultimap(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandReactiveService ca = new CommandReactiveService(commandExecutor, params);
return ReactiveProxyBuilder.create(commandExecutor, new RedissonListMultimap<K, V>(params.getCodec(), ca, params.getName()),
new RedissonListMultimapReactive<K, V>(params.getCodec(), ca, params.getName()), RListMultimapReactive.class);
}
@Override
public <K, V> RSetMultimapReactive<K, V> getSetMultimap(String name) {
return ReactiveProxyBuilder.create(commandExecutor, new RedissonSetMultimap<K, V>(commandExecutor, name),
@ -293,6 +446,14 @@ public class RedissonReactive implements RedissonReactiveClient {
new RedissonSetMultimapReactive<K, V>(codec, commandExecutor, name, this), RSetMultimapReactive.class);
}
@Override
public <K, V> RSetMultimapReactive<K, V> getSetMultimap(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandReactiveService ca = new CommandReactiveService(commandExecutor, params);
return ReactiveProxyBuilder.create(commandExecutor, new RedissonSetMultimap<K, V>(params.getCodec(), ca, params.getName()),
new RedissonSetMultimapReactive<K, V>(params.getCodec(), ca, params.getName(), this), RSetMultimapReactive.class);
}
@Override
public <K, V> RListMultimapCacheReactive<K, V> getListMultimapCache(String name) {
RedissonListMultimapCache<K, V> listMultimap = new RedissonListMultimapCache<>(evictionScheduler, commandExecutor, name);
@ -307,6 +468,15 @@ public class RedissonReactive implements RedissonReactiveClient {
new RedissonListMultimapCacheReactive<>(listMultimap, commandExecutor), RListMultimapCacheReactive.class);
}
@Override
public <K, V> RListMultimapCacheReactive<K, V> getListMultimapCache(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandReactiveService ca = new CommandReactiveService(commandExecutor, params);
RedissonListMultimapCache<K, V> listMultimap = new RedissonListMultimapCache<>(evictionScheduler, params.getCodec(), ca, params.getName());
return ReactiveProxyBuilder.create(commandExecutor, listMultimap,
new RedissonListMultimapCacheReactive<>(listMultimap, ca), RListMultimapCacheReactive.class);
}
@Override
public <K, V> RSetMultimapCacheReactive<K, V> getSetMultimapCache(String name) {
RedissonSetMultimapCache<K, V> setMultimap = new RedissonSetMultimapCache<>(evictionScheduler, commandExecutor, name);
@ -321,20 +491,38 @@ public class RedissonReactive implements RedissonReactiveClient {
new RedissonSetMultimapCacheReactive<K, V>(setMultimap, commandExecutor, this), RSetMultimapCacheReactive.class);
}
@Override
public <K, V> RSetMultimapCacheReactive<K, V> getSetMultimapCache(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandReactiveService ca = new CommandReactiveService(commandExecutor, params);
RedissonSetMultimapCache<K, V> setMultimap = new RedissonSetMultimapCache<>(evictionScheduler, params.getCodec(), ca, params.getName());
return ReactiveProxyBuilder.create(commandExecutor, setMultimap,
new RedissonSetMultimapCacheReactive<K, V>(setMultimap, ca, this), RSetMultimapCacheReactive.class);
}
@Override
public <K, V> RMapReactive<K, V> getMap(String name) {
RedissonMap<K, V> map = new RedissonMap<K, V>(commandExecutor, name, null, null, null);
RedissonMap<K, V> map = new RedissonMap<K, V>(commandExecutor, name, null, null, writeBehindService);
return ReactiveProxyBuilder.create(commandExecutor, map,
new RedissonMapReactive<K, V>(map, commandExecutor), RMapReactive.class);
}
@Override
public <K, V> RMapReactive<K, V> getMap(String name, Codec codec) {
RedissonMap<K, V> map = new RedissonMap<K, V>(codec, commandExecutor, name, null, null, null);
RedissonMap<K, V> map = new RedissonMap<K, V>(codec, commandExecutor, name, null, null, writeBehindService);
return ReactiveProxyBuilder.create(commandExecutor, map,
new RedissonMapReactive<K, V>(map, commandExecutor), RMapReactive.class);
}
@Override
public <K, V> RMapReactive<K, V> getMap(org.redisson.api.options.MapOptions<K, V> options) {
MapParams<K, V> params = (MapParams<K, V>) options;
CommandReactiveService ca = new CommandReactiveService(commandExecutor, params);
RedissonMap<K, V> map = new RedissonMap<>(params.getCodec(), ca, params.getName(), null, null, writeBehindService);
return ReactiveProxyBuilder.create(commandExecutor, map,
new RedissonMapReactive<K, V>(map, ca), RMapReactive.class);
}
@Override
public <V> RSetReactive<V> getSet(String name) {
RedissonSet<V> set = new RedissonSet<V>(commandExecutor, name, null);
@ -349,6 +537,15 @@ public class RedissonReactive implements RedissonReactiveClient {
new RedissonSetReactive<V>(set, this), RSetReactive.class);
}
@Override
public <V> RSetReactive<V> getSet(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandAsyncService ca = new CommandAsyncService(commandExecutor, params);
RedissonSet<V> set = new RedissonSet<V>(params.getCodec(), ca, params.getName(), null);
return ReactiveProxyBuilder.create(commandExecutor, set,
new RedissonSetReactive<V>(set, this), RSetReactive.class);
}
@Override
public <V> RScoredSortedSetReactive<V> getScoredSortedSet(String name) {
return ReactiveProxyBuilder.create(commandExecutor, new RedissonScoredSortedSet<V>(commandExecutor, name, null),
@ -361,6 +558,14 @@ public class RedissonReactive implements RedissonReactiveClient {
new RedissonScoredSortedSetReactive<V>(codec, commandExecutor, name), RScoredSortedSetReactive.class);
}
@Override
public <V> RScoredSortedSetReactive<V> getScoredSortedSet(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandReactiveService ca = new CommandReactiveService(commandExecutor, params);
return ReactiveProxyBuilder.create(commandExecutor, new RedissonScoredSortedSet<V>(params.getCodec(), ca, params.getName(), null),
new RedissonScoredSortedSetReactive<V>(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 <V> RQueueReactive<V> getQueue(String name) {
return ReactiveProxyBuilder.create(commandExecutor, new RedissonQueue<V>(commandExecutor, name, null),
@ -432,7 +682,15 @@ public class RedissonReactive implements RedissonReactiveClient {
return ReactiveProxyBuilder.create(commandExecutor, new RedissonQueue<V>(codec, commandExecutor, name, null),
new RedissonListReactive<V>(codec, commandExecutor, name), RQueueReactive.class);
}
@Override
public <V> RQueueReactive<V> getQueue(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandReactiveService ca = new CommandReactiveService(commandExecutor, params);
return ReactiveProxyBuilder.create(commandExecutor, new RedissonQueue<V>(params.getCodec(), ca, params.getName(), null),
new RedissonListReactive<V>(params.getCodec(), ca, params.getName()), RQueueReactive.class);
}
@Override
public <V> RRingBufferReactive<V> getRingBuffer(String name) {
return ReactiveProxyBuilder.create(commandExecutor, new RedissonRingBuffer<V>(commandExecutor, name, null), RRingBufferReactive.class);
@ -443,6 +701,14 @@ public class RedissonReactive implements RedissonReactiveClient {
return ReactiveProxyBuilder.create(commandExecutor, new RedissonRingBuffer<V>(codec, commandExecutor, name, null), RRingBufferReactive.class);
}
@Override
public <V> RRingBufferReactive<V> getRingBuffer(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandAsyncService ca = new CommandAsyncService(commandExecutor, params);
return ReactiveProxyBuilder.create(commandExecutor,
new RedissonRingBuffer<V>(params.getCodec(), ca, params.getName(), null), RRingBufferReactive.class);
}
@Override
public <V> RBlockingQueueReactive<V> getBlockingQueue(String name) {
RedissonBlockingQueue<V> queue = new RedissonBlockingQueue<V>(commandExecutor, name, null);
@ -457,6 +723,15 @@ public class RedissonReactive implements RedissonReactiveClient {
new RedissonBlockingQueueReactive<V>(queue), RBlockingQueueReactive.class);
}
@Override
public <V> RBlockingQueueReactive<V> getBlockingQueue(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandAsyncService ca = new CommandAsyncService(commandExecutor, params);
RedissonBlockingQueue<V> queue = new RedissonBlockingQueue<V>(params.getCodec(), ca, params.getName(), null);
return ReactiveProxyBuilder.create(commandExecutor, queue,
new RedissonBlockingQueueReactive<V>(queue), RBlockingQueueReactive.class);
}
@Override
public <V> RDequeReactive<V> getDeque(String name) {
return ReactiveProxyBuilder.create(commandExecutor, new RedissonDeque<V>(commandExecutor, name, null),
@ -469,6 +744,14 @@ public class RedissonReactive implements RedissonReactiveClient {
new RedissonListReactive<V>(codec, commandExecutor, name), RDequeReactive.class);
}
@Override
public <V> RDequeReactive<V> getDeque(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandReactiveService ca = new CommandReactiveService(commandExecutor, params);
return ReactiveProxyBuilder.create(commandExecutor, new RedissonDeque<V>(params.getCodec(), ca, params.getName(), null),
new RedissonListReactive<V>(params.getCodec(), ca, params.getName()), RDequeReactive.class);
}
@Override
public <V, L> RTimeSeriesReactive<V, L> getTimeSeries(String name) {
RTimeSeries<V, L> timeSeries = new RedissonTimeSeries<V, L>(evictionScheduler, commandExecutor, name);
@ -483,6 +766,15 @@ public class RedissonReactive implements RedissonReactiveClient {
new RedissonTimeSeriesReactive<V, L>(timeSeries, this), RTimeSeriesReactive.class);
}
@Override
public <V, L> RTimeSeriesReactive<V, L> getTimeSeries(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandAsyncService ca = new CommandAsyncService(commandExecutor, params);
RTimeSeries<V, L> timeSeries = new RedissonTimeSeries<>(params.getCodec(), evictionScheduler, ca, params.getName());
return ReactiveProxyBuilder.create(commandExecutor, timeSeries,
new RedissonTimeSeriesReactive<V, L>(timeSeries, this), RTimeSeriesReactive.class);
}
@Override
public <V> RSetCacheReactive<V> getSetCache(String name) {
RSetCache<V> set = new RedissonSetCache<V>(evictionScheduler, commandExecutor, name, null);
@ -497,16 +789,40 @@ public class RedissonReactive implements RedissonReactiveClient {
new RedissonSetCacheReactive<V>(set, this), RSetCacheReactive.class);
}
@Override
public <V> RSetCacheReactive<V> getSetCache(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandAsyncService ca = new CommandAsyncService(commandExecutor, params);
RSetCache<V> set = new RedissonSetCache<V>(params.getCodec(), evictionScheduler, ca, params.getName(), null);
return ReactiveProxyBuilder.create(commandExecutor, set,
new RedissonSetCacheReactive<V>(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 <K, V> RLocalCachedMapReactive<K, V> getLocalCachedMap(org.redisson.api.options.LocalCachedMapOptions<K, V> options) {
LocalCachedMapParams<K, V> params = (LocalCachedMapParams) options;
LocalCachedMapOptions<K, V> ops = LocalCachedMapOptions.<K, V>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<K, V> 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<V>(deque), RBlockingDequeReactive.class);
}
@Override
public <V> RBlockingDequeReactive<V> getBlockingDeque(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandAsyncService ca = new CommandAsyncService(commandExecutor, params);
RedissonBlockingDeque<V> deque = new RedissonBlockingDeque<V>(params.getCodec(), ca, params.getName(), null);
return ReactiveProxyBuilder.create(commandExecutor, deque,
new RedissonBlockingDequeReactive<V>(deque), RBlockingDequeReactive.class);
}
@Override
public <V> RTransferQueueReactive<V> getTransferQueue(String name) {
String remoteName = RedissonObject.suffixName(name, "remoteService");
@ -687,6 +1083,17 @@ public class RedissonReactive implements RedissonReactiveClient {
new RedissonTransferQueueReactive<V>(queue), RTransferQueueReactive.class);
}
@Override
public <V> RTransferQueueReactive<V> 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<V> queue = new RedissonTransferQueue<V>(params.getCodec(), ca, params.getName(), service);
return ReactiveProxyBuilder.create(commandExecutor, queue,
new RedissonTransferQueueReactive<V>(queue), RTransferQueueReactive.class);
}
@Override
public String getId() {
return commandExecutor.getServiceManager().getId();

@ -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<K, V>(codec, commandExecutor, name), RStreamRx.class);
}
@Override
public <K, V> RStreamRx<K, V> getStream(PlainOptions options) {
PlainParams params = (PlainParams) options;
return RxProxyBuilder.create(commandExecutor,
new RedissonStream<K, V>(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 <V> RGeoRx<V> getGeo(String name) {
RedissonScoredSortedSet<V> set = new RedissonScoredSortedSet<V>(commandExecutor, name, null);
@ -102,17 +123,40 @@ public class RedissonRx implements RedissonRxClient {
return RxProxyBuilder.create(commandExecutor, new RedissonGeo<V>(codec, commandExecutor, name, null),
new RedissonScoredSortedSetRx<V>(set), RGeoRx.class);
}
@Override
public <V> RGeoRx<V> getGeo(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandAsyncService ce = new CommandAsyncService(commandExecutor, params);
RedissonScoredSortedSet<V> set = new RedissonScoredSortedSet<V>(params.getCodec(), ce, params.getName(), null);
return RxProxyBuilder.create(commandExecutor, new RedissonGeo<V>(params.getCodec(), ce, params.getName(), null),
new RedissonScoredSortedSetRx<V>(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 <K, V> RMapCacheRx<K, V> getMapCache(String name, Codec codec) {
RMap<K, V> map = new RedissonMapCache<K, V>(codec, evictionScheduler, commandExecutor, name, null, null, null);
@ -194,6 +291,31 @@ public class RedissonRx implements RedissonRxClient {
new RedissonMapCacheRx<K, V>(map, commandExecutor), RMapCacheRx.class);
}
@Override
public <K, V> RMapCacheRx<K, V> getMapCache(org.redisson.api.options.MapCacheOptions<K, V> options) {
MapCacheParams<K, V> params = (MapCacheParams<K, V>) options;
MapCacheOptions<K, V> ops = MapCacheOptions.<K, V>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<K, V> map = new RedissonMapCache<>(params.getCodec(), evictionScheduler,
ce, params.getName(), null, ops, writeBehindService);
return RxProxyBuilder.create(commandExecutor, map,
new RedissonMapCacheRx<K, V>(map, ce), RMapCacheRx.class);
}
@Override
public <V> RBucketRx<V> getBucket(String name) {
return RxProxyBuilder.create(commandExecutor, new RedissonBucket<V>(commandExecutor, name), RBucketRx.class);
@ -204,6 +326,14 @@ public class RedissonRx implements RedissonRxClient {
return RxProxyBuilder.create(commandExecutor, new RedissonBucket<V>(codec, commandExecutor, name), RBucketRx.class);
}
@Override
public <V> RBucketRx<V> getBucket(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandRxService ce = new CommandRxService(commandExecutor, params);
return RxProxyBuilder.create(commandExecutor,
new RedissonBucket<V>(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 <V> RJsonBucketRx<V> getJsonBucket(String name, JsonCodec<V> codec) {
return RxProxyBuilder.create(commandExecutor, new RedissonJsonBucket<>(codec, commandExecutor, name), RJsonBucketRx.class);
}
@Override
public <V> RJsonBucketRx<V> getJsonBucket(JsonBucketOptions<V> options) {
JsonBucketParams<V> params = (JsonBucketParams<V>) options;
CommandAsyncService ce = new CommandAsyncService(commandExecutor, params);
return RxProxyBuilder.create(commandExecutor, new RedissonJsonBucket<>(params.getCodec(), ce, params.getName()), RJsonBucketRx.class);
}
@Override
public <V> RHyperLogLogRx<V> getHyperLogLog(String name) {
return RxProxyBuilder.create(commandExecutor, new RedissonHyperLogLog<V>(commandExecutor, name), RHyperLogLogRx.class);
@ -229,11 +373,25 @@ public class RedissonRx implements RedissonRxClient {
return RxProxyBuilder.create(commandExecutor, new RedissonHyperLogLog<V>(codec, commandExecutor, name), RHyperLogLogRx.class);
}
@Override
public <V> RHyperLogLogRx<V> getHyperLogLog(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandAsyncService ce = new CommandAsyncService(commandExecutor, params);
return RxProxyBuilder.create(commandExecutor, new RedissonHyperLogLog<V>(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 <V> RListRx<V> getList(String name) {
RedissonList<V> list = new RedissonList<V>(commandExecutor, name, null);
@ -248,6 +406,15 @@ public class RedissonRx implements RedissonRxClient {
new RedissonListRx<V>(list), RListRx.class);
}
@Override
public <V> RListRx<V> getList(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandAsyncService ce = new CommandAsyncService(commandExecutor, params);
RedissonList<V> list = new RedissonList<V>(params.getCodec(), ce, params.getName(), null);
return RxProxyBuilder.create(commandExecutor, list,
new RedissonListRx<V>(list), RListRx.class);
}
@Override
public <K, V> RListMultimapRx<K, V> getListMultimap(String name) {
RedissonListMultimap<K, V> listMultimap = new RedissonListMultimap<>(commandExecutor, name);
@ -262,6 +429,15 @@ public class RedissonRx implements RedissonRxClient {
new RedissonListMultimapRx<K, V>(listMultimap, commandExecutor), RListMultimapRx.class);
}
@Override
public <K, V> RListMultimapRx<K, V> getListMultimap(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandAsyncService ce = new CommandAsyncService(commandExecutor, params);
RedissonListMultimap<K, V> listMultimap = new RedissonListMultimap<>(params.getCodec(), ce, params.getName());
return RxProxyBuilder.create(commandExecutor, listMultimap,
new RedissonListMultimapRx<K, V>(listMultimap, commandExecutor), RListMultimapRx.class);
}
@Override
public <K, V> RListMultimapCacheRx<K, V> getListMultimapCache(String name) {
RedissonListMultimapCache<K, V> listMultimap = new RedissonListMultimapCache<>(evictionScheduler, commandExecutor, name);
@ -276,6 +452,15 @@ public class RedissonRx implements RedissonRxClient {
new RedissonListMultimapCacheRx<K, V>(listMultimap, commandExecutor), RListMultimapCacheRx.class);
}
@Override
public <K, V> RListMultimapCacheRx<K, V> getListMultimapCache(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandRxService ce = new CommandRxService(commandExecutor, params);
RedissonListMultimapCache<K, V> listMultimap = new RedissonListMultimapCache<>(evictionScheduler, params.getCodec(), ce, params.getName());
return RxProxyBuilder.create(commandExecutor, listMultimap,
new RedissonListMultimapCacheRx<K, V>(listMultimap, ce), RListMultimapCacheRx.class);
}
@Override
public <K, V> RSetMultimapRx<K, V> getSetMultimap(String name) {
RedissonSetMultimap<K, V> setMultimap = new RedissonSetMultimap<>(commandExecutor, name);
@ -290,6 +475,15 @@ public class RedissonRx implements RedissonRxClient {
new RedissonSetMultimapRx<K, V>(setMultimap, commandExecutor, this), RSetMultimapRx.class);
}
@Override
public <K, V> RSetMultimapRx<K, V> getSetMultimap(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandRxService ce = new CommandRxService(commandExecutor, params);
RedissonSetMultimap<K, V> setMultimap = new RedissonSetMultimap<>(params.getCodec(), ce, params.getName());
return RxProxyBuilder.create(commandExecutor, setMultimap,
new RedissonSetMultimapRx<>(setMultimap, ce, this), RSetMultimapRx.class);
}
@Override
public <K, V> RSetMultimapCacheRx<K, V> getSetMultimapCache(String name) {
RedissonSetMultimapCache<K, V> setMultimap = new RedissonSetMultimapCache<>(evictionScheduler, commandExecutor, name);
@ -304,6 +498,15 @@ public class RedissonRx implements RedissonRxClient {
new RedissonSetMultimapCacheRx<K, V>(setMultimap, commandExecutor, this), RSetMultimapCacheRx.class);
}
@Override
public <K, V> RSetMultimapCacheRx<K, V> getSetMultimapCache(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandRxService ce = new CommandRxService(commandExecutor, params);
RedissonSetMultimapCache<K, V> setMultimap = new RedissonSetMultimapCache<>(evictionScheduler, params.getCodec(), ce, params.getName());
return RxProxyBuilder.create(commandExecutor, setMultimap,
new RedissonSetMultimapCacheRx<>(setMultimap, ce, this), RSetMultimapCacheRx.class);
}
@Override
public <K, V> RMapRx<K, V> getMap(String name) {
RedissonMap<K, V> map = new RedissonMap<K, V>(commandExecutor, name, null, null, null);
@ -318,6 +521,15 @@ public class RedissonRx implements RedissonRxClient {
new RedissonMapRx<K, V>(map, commandExecutor), RMapRx.class);
}
@Override
public <K, V> RMapRx<K, V> getMap(org.redisson.api.options.MapOptions<K, V> options) {
MapParams<K, V> params = (MapParams<K, V>) options;
CommandRxService ce = new CommandRxService(commandExecutor, params);
RedissonMap<K, V> map = new RedissonMap<>(params.getCodec(), ce, params.getName(), null, null, writeBehindService);
return RxProxyBuilder.create(commandExecutor, map,
new RedissonMapRx<>(map, ce), RMapRx.class);
}
@Override
public <V> RSetRx<V> getSet(String name) {
RedissonSet<V> set = new RedissonSet<V>(commandExecutor, name, null);
@ -332,6 +544,15 @@ public class RedissonRx implements RedissonRxClient {
new RedissonSetRx<V>(set, this), RSetRx.class);
}
@Override
public <V> RSetRx<V> getSet(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandAsyncService ce = new CommandAsyncService(commandExecutor, params);
RedissonSet<V> set = new RedissonSet<V>(params.getCodec(), ce, params.getName(), null);
return RxProxyBuilder.create(commandExecutor, set,
new RedissonSetRx<V>(set, this), RSetRx.class);
}
@Override
public <V> RScoredSortedSetRx<V> getScoredSortedSet(String name) {
RedissonScoredSortedSet<V> set = new RedissonScoredSortedSet<V>(commandExecutor, name, null);
@ -346,6 +567,15 @@ public class RedissonRx implements RedissonRxClient {
new RedissonScoredSortedSetRx<V>(set), RScoredSortedSetRx.class);
}
@Override
public <V> RScoredSortedSetRx<V> getScoredSortedSet(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandAsyncService ce = new CommandAsyncService(commandExecutor, params);
RedissonScoredSortedSet<V> set = new RedissonScoredSortedSet<V>(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 <V> RQueueRx<V> getQueue(String name) {
return RxProxyBuilder.create(commandExecutor, new RedissonQueue<V>(commandExecutor, name, null),
@ -409,6 +679,14 @@ public class RedissonRx implements RedissonRxClient {
new RedissonListRx<V>(new RedissonList<V>(codec, commandExecutor, name, null)), RQueueRx.class);
}
@Override
public <V> RQueueRx<V> getQueue(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandAsyncService ce = new CommandAsyncService(commandExecutor, params);
return RxProxyBuilder.create(commandExecutor, new RedissonQueue<V>(params.getCodec(), ce, params.getName(), null),
new RedissonListRx<V>(new RedissonList<V>(params.getCodec(), ce, params.getName(), null)), RQueueRx.class);
}
@Override
public <V> RRingBufferRx<V> getRingBuffer(String name) {
return RxProxyBuilder.create(commandExecutor, new RedissonRingBuffer<V>(commandExecutor, name, null), RRingBufferRx.class);
@ -419,6 +697,14 @@ public class RedissonRx implements RedissonRxClient {
return RxProxyBuilder.create(commandExecutor, new RedissonRingBuffer<V>(codec, commandExecutor, name, null), RRingBufferRx.class);
}
@Override
public <V> RRingBufferRx<V> getRingBuffer(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandAsyncService ce = new CommandAsyncService(commandExecutor, params);
return RxProxyBuilder.create(commandExecutor,
new RedissonRingBuffer<V>(params.getCodec(), ce, params.getName(), null), RRingBufferRx.class);
}
@Override
public <V> RBlockingQueueRx<V> getBlockingQueue(String name) {
RedissonBlockingQueue<V> queue = new RedissonBlockingQueue<V>(commandExecutor, name, null);
@ -433,6 +719,15 @@ public class RedissonRx implements RedissonRxClient {
new RedissonBlockingQueueRx<V>(queue), RBlockingQueueRx.class);
}
@Override
public <V> RBlockingQueueRx<V> getBlockingQueue(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandAsyncService ce = new CommandAsyncService(commandExecutor, params);
RedissonBlockingQueue<V> queue = new RedissonBlockingQueue<V>(params.getCodec(), ce, params.getName(), null);
return RxProxyBuilder.create(commandExecutor, queue,
new RedissonBlockingQueueRx<V>(queue), RBlockingQueueRx.class);
}
@Override
public <V> RDequeRx<V> getDeque(String name) {
RedissonDeque<V> queue = new RedissonDeque<V>(commandExecutor, name, null);
@ -447,6 +742,15 @@ public class RedissonRx implements RedissonRxClient {
new RedissonListRx<V>(queue), RDequeRx.class);
}
@Override
public <V> RDequeRx<V> getDeque(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandAsyncService ce = new CommandAsyncService(commandExecutor, params);
RedissonDeque<V> queue = new RedissonDeque<V>(params.getCodec(), ce, params.getName(), null);
return RxProxyBuilder.create(commandExecutor, queue,
new RedissonListRx<V>(queue), RDequeRx.class);
}
@Override
public <V, L> RTimeSeriesRx<V, L> getTimeSeries(String name) {
RTimeSeries<V, L> timeSeries = new RedissonTimeSeries<V, L>(evictionScheduler, commandExecutor, name);
@ -461,6 +765,15 @@ public class RedissonRx implements RedissonRxClient {
new RedissonTimeSeriesRx<V, L>(timeSeries, this), RTimeSeriesRx.class);
}
@Override
public <V, L> RTimeSeriesRx<V, L> getTimeSeries(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandAsyncService ce = new CommandAsyncService(commandExecutor, params);
RTimeSeries<V, L> timeSeries = new RedissonTimeSeries<>(params.getCodec(), evictionScheduler, ce, params.getName());
return RxProxyBuilder.create(commandExecutor, timeSeries,
new RedissonTimeSeriesRx<>(timeSeries, this), RTimeSeriesRx.class);
}
@Override
public <V> RSetCacheRx<V> getSetCache(String name) {
RSetCache<V> set = new RedissonSetCache<V>(evictionScheduler, commandExecutor, name, null);
@ -475,16 +788,39 @@ public class RedissonRx implements RedissonRxClient {
new RedissonSetCacheRx<V>(set, this), RSetCacheRx.class);
}
@Override
public <V> RSetCacheRx<V> getSetCache(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandAsyncService ce = new CommandAsyncService(commandExecutor, params);
RSetCache<V> set = new RedissonSetCache<V>(params.getCodec(), evictionScheduler, ce, params.getName(), null);
return RxProxyBuilder.create(commandExecutor, set,
new RedissonSetCacheRx<V>(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 <K, V> RLocalCachedMapRx<K, V> getLocalCachedMap(org.redisson.api.options.LocalCachedMapOptions<K, V> options) {
LocalCachedMapParams<K, V> params = (LocalCachedMapParams) options;
LocalCachedMapOptions<K, V> ops = LocalCachedMapOptions.<K, V>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<K, V> 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<V>(deque), RBlockingDequeRx.class);
}
@Override
public <V> RBlockingDequeRx<V> getBlockingDeque(PlainOptions options) {
PlainParams params = (PlainParams) options;
CommandAsyncService ce = new CommandAsyncService(commandExecutor, params);
RedissonBlockingDeque<V> deque = new RedissonBlockingDeque<V>(params.getCodec(), ce, params.getName(), null);
return RxProxyBuilder.create(commandExecutor, deque,
new RedissonBlockingDequeRx<V>(deque), RBlockingDequeRx.class);
}
@Override
public <V> RTransferQueueRx<V> getTransferQueue(String name) {
String remoteName = RedissonObject.suffixName(name, "remoteService");
@ -664,6 +1081,17 @@ public class RedissonRx implements RedissonRxClient {
new RedissonTransferQueueRx<V>(queue), RTransferQueueRx.class);
}
@Override
public <V> RTransferQueueRx<V> 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<V> queue = new RedissonTransferQueue<V>(params.getCodec(), ce, params.getName(), service);
return RxProxyBuilder.create(commandExecutor, queue,
new RedissonTransferQueueRx<V>(queue), RTransferQueueRx.class);
}
@Override
public String getId() {
return commandExecutor.getServiceManager().getId();

@ -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

@ -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;
}

@ -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();
}

@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit;
* @author Nikita Koksharov
*
*/
@Deprecated
public final class ExecutorOptions {
private long taskRetryInterval = 5 * 60000;

@ -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 <K> key type
* @param <V> value type
*/
@Deprecated
public class LocalCachedMapOptions<K, V> extends MapOptions<K, V> {
/**
@ -428,4 +430,14 @@ public class LocalCachedMapOptions<K, V> extends MapOptions<K, V> {
public LocalCachedMapOptions<K, V> loaderAsync(MapLoaderAsync<K, V> loaderAsync) {
return (LocalCachedMapOptions<K, V>) super.loaderAsync(loaderAsync);
}
@Override
public LocalCachedMapOptions<K, V> writerRetryAttempts(int writerRetryAttempts) {
return (LocalCachedMapOptions<K, V>) super.writerRetryAttempts(writerRetryAttempts);
}
@Override
public LocalCachedMapOptions<K, V> writerRetryInterval(Duration writerRetryInterval) {
return (LocalCachedMapOptions<K, V>) super.writerRetryInterval(writerRetryInterval);
}
}

@ -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<K, V> extends MapOptions<K, V> {
return (MapCacheOptions<K, V>) super.loaderAsync(loaderAsync);
}
@Override
public MapCacheOptions<K, V> writerRetryAttempts(int writerRetryAttempts) {
return (MapCacheOptions<K, V>) super.writerRetryAttempts(writerRetryAttempts);
}
@Override
public MapCacheOptions<K, V> writerRetryInterval(Duration writerRetryInterval) {
return (MapCacheOptions<K, V>) super.writerRetryInterval(writerRetryInterval);
}
public boolean isRemoveEmptyEvictionTask() {
return removeEmptyEvictionTask;
}

@ -32,6 +32,7 @@ import java.time.Duration;
* @param <K> key type
* @param <V> value type
*/
@Deprecated
public class MapOptions<K, V> {
public enum WriteMode {

File diff suppressed because it is too large Load Diff

@ -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
}

@ -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<T extends ExMapOptions<T, K, V>, K, V> extends BaseOptions<T, Codec>
implements ExMapOptions<T, K, V> {
private int writeRetryAttempts;
private MapWriter<K, V> writer;
private MapWriterAsync<K, V> writerAsync;
private int writeBehindBatchSize;
private int writeBehindDelay;
private WriteMode writeMode;
private long writeRetryInterval;
private MapLoader<K, V> loader;
private MapLoaderAsync<K, V> loaderAsync;
public T writer(MapWriter<K, V> writer) {
if (writer != null) {
org.redisson.api.MapOptions<K, V> options = (org.redisson.api.MapOptions<K, V>) org.redisson.api.MapOptions.defaults()
.writerRetryAttempts(getWriteRetryAttempts())
.writerRetryInterval(Duration.ofMillis(getWriteRetryInterval()));
this.writer = new RetryableMapWriter<>(options, writer);
}
return (T) this;
}
public MapWriter<K, V> getWriter() {
return writer;
}
public T writerAsync(MapWriterAsync<K, V> writer) {
if (writer != null) {
org.redisson.api.MapOptions<K, V> options = (org.redisson.api.MapOptions<K, V>) org.redisson.api.MapOptions.defaults()
.writerRetryAttempts(getWriteRetryAttempts())
.writerRetryInterval(Duration.ofMillis(getWriteRetryInterval()));
this.writerAsync = new RetryableMapWriterAsync<>(options, writer);
}
return (T) this;
}
public MapWriterAsync<K, V> 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<K, V> loader) {
this.loader = loader;
return (T) this;
}
public MapLoader<K, V> getLoader() {
return loader;
}
public T loaderAsync(MapLoaderAsync<K, V> loaderAsync) {
this.loaderAsync = loaderAsync;
return (T) this;
}
public MapLoaderAsync<K, V> getLoaderAsync() {
return loaderAsync;
}
}

@ -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<T extends InvocationOptions<T>, C> implements CodecOptions<T, C>, 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;
}
}

@ -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<T extends InvocationOptions<T>, C> extends InvocationOptions<T> {
/**
* Defines codec used for data stored in Redis
*
* @param codec applied to object instance
* @return options object
*/
T codec(C codec);
}

@ -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<CommonOptions> {
/**
* 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);
}
}

@ -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<CommonOptions, Codec> implements CommonOptions {
private final String name;
CommonParams(String name) {
this.name = name;
}
public String getName() {
return name;
}
}

@ -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 <T> returned object type
* @param <K> type of key
* @param <V> type of value
*/
public interface ExMapOptions<T extends ExMapOptions<T, K, V>, K, V> extends CodecOptions<T, Codec> {
/**
* Defines {@link MapWriter} object which is invoked during write operation.
*
* @param writer object
* @return MapOptions instance
*/
T writer(MapWriter<K, V> writer);
/**
* Defines {@link MapWriterAsync} object which is invoked during write operation.
*
* @param writer object
* @return MapOptions instance
*/
T writerAsync(MapWriterAsync<K, V> writer);
/**
* Sets write behind tasks batch size.
* All updates accumulated into a batch of specified size and written with {@link MapWriter}.
* <p>
* Default is <code>50</code>
*
* @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.
* <p>
* Default is <code>1000</code> milliseconds
*
* @param writeBehindDelay delay in milliseconds
* @return MapOptions instance
*/
T writeBehindDelay(int writeBehindDelay);
/**
* Sets write mode.
* <p>
* Default is <code>{@link WriteMode#WRITE_THROUGH}</code>
*
* @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<K, V> loader);
/**
* Sets {@link MapLoaderAsync} object.
*
* @param loaderAsync object
* @return MapOptions instance
*/
T loaderAsync(MapLoaderAsync<K, V> loaderAsync);
}

@ -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<ExecutorOptions, Codec> {
/**
* 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.
* <p>
* 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).
* <p>
* Set <code>0</code> to disable.
* <p>
* Default is <code>5 minutes</code>
*
* @param interval value
* @return options instance
*/
ExecutorOptions taskRetryInterval(Duration interval);
/**
* Defines identifier generator
*
* @param idGenerator identifier generator
* @return options instance
*/
ExecutorOptions idGenerator(IdGenerator idGenerator);
}

@ -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<ExecutorOptions, Codec> 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;
}
}

@ -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<T extends InvocationOptions<T>> {
/**
* Defines Redis server response timeout. Starts to countdown
* when a Redis command was successfully sent.
* <p>
* 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 <code>retryAttempts</code>.
* But if it sent successfully then <code>responseTimeout</code> is started.
* <p>
* 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);
}

@ -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<V> extends CodecOptions<JsonBucketOptions<V>, JsonCodec<V>> {
/**
* Creates options with the name of object instance
*
* @param name of object instance
* @return options instance
*/
static <V> JsonBucketOptions<V> name(String name) {
return new JsonBucketParams<>(name);
}
}

@ -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<V> extends BaseOptions<JsonBucketOptions<V>, JsonCodec<V>> implements JsonBucketOptions<V> {
private final String name;
JsonBucketParams(String name) {
this.name = name;
}
public String getName() {
return name;
}
}

@ -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<KeysOptions> {
/**
* Creates the default options
*
* @return options instance
*/
static KeysOptions defaults() {
return new KeysParams();
}
}

@ -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<KeysOptions, Codec> implements KeysOptions {
KeysParams() {
}
}

@ -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<LiveObjectOptions> {
/**
* Creates the default options
*
* @return options instance
*/
static LiveObjectOptions defaults() {
return new LiveObjectParams();
}
}

@ -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<LiveObjectOptions, Codec> implements LiveObjectOptions {
LiveObjectParams() {
}
}

@ -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 <K> key type
* @param <V> value type
*/
public interface LocalCachedMapOptions<K, V> extends ExMapOptions<LocalCachedMapOptions<K, V>, 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 <K, V> LocalCachedMapOptions<K, V> name(String name) {
return new LocalCachedMapParams<>(name);
}
/**
* Defines local cache size.
* <p>
* If size is <code>0</code> then local cache is unbounded.
* <p>
* If size is <code>-1</code> then local cache is always empty and doesn't store data.
*
* @param cacheSize size of cache
* @return LocalCachedMapOptions instance
*/
LocalCachedMapOptions<K, V> cacheSize(int cacheSize);
/**
* Defines strategy for load missed local cache updates after Redis connection failure.
*
* @param reconnectionStrategy
* <p><code>CLEAR</code> - clear local cache if map instance has been disconnected for a while.
* <p><code>LOAD</code> - 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
* <p><code>NONE</code> - Default. No reconnection handling
* @return LocalCachedMapOptions instance
*/
LocalCachedMapOptions<K, V> reconnectionStrategy(ReconnectionStrategy reconnectionStrategy);
/**
* Defines local cache synchronization strategy.
*
* @param syncStrategy
* <p><code>INVALIDATE</code> - Default. Invalidate cache entry across all LocalCachedMap instances on map entry change
* <p><code>UPDATE</code> - Insert/update cache entry across all LocalCachedMap instances on map entry change
* <p><code>NONE</code> - No synchronizations on map changes
* @return LocalCachedMapOptions instance
*/
LocalCachedMapOptions<K, V> syncStrategy(SyncStrategy syncStrategy);
/**
* Defines local cache eviction policy.
*
* @param evictionPolicy
* <p><code>LRU</code> - uses local cache with LRU (least recently used) eviction policy.
* <p><code>LFU</code> - uses local cache with LFU (least frequently used) eviction policy.
* <p><code>SOFT</code> - uses local cache with soft references. The garbage collector will evict items from the local cache when the JVM is running out of memory.
* <p><code>WEAK</code> - uses local cache with weak references. The garbage collector will evict items from the local cache when it became weakly reachable.
* <p><code>NONE</code> - doesn't use eviction policy, but timeToLive and maxIdleTime params are still working.
* @return LocalCachedMapOptions instance
*/
LocalCachedMapOptions<K, V> evictionPolicy(EvictionPolicy evictionPolicy);
/**
* Defines time to live in milliseconds of each map entry in local cache.
* If value equals to <code>0</code> then timeout is not applied
*
* @param ttl - time to live in milliseconds
* @return LocalCachedMapOptions instance
*/
LocalCachedMapOptions<K, V> timeToLive(Duration ttl);
/**
* Defines max idle time in milliseconds of each map entry in local cache.
* If value equals to <code>0</code> then timeout is not applied
*
* @param idleTime time to live in milliseconds
* @return LocalCachedMapOptions instance
*/
LocalCachedMapOptions<K, V> maxIdle(Duration idleTime);
/**
* Defines store mode of cache data.
*
* @param storeMode <p><code>LOCALCACHE</code> - store data in local cache only.
* <p><code>LOCALCACHE_REDIS</code> - store data in both Redis and local cache.
* @return LocalCachedMapOptions instance
*/
LocalCachedMapOptions<K, V> storeMode(StoreMode storeMode);
/**
* Defines Cache provider used as local cache store.
*
* @param cacheProvider <p><code>REDISSON</code> - uses Redisson own implementation.
* <p><code>CAFFEINE</code> - uses Caffeine implementation.
* @return LocalCachedMapOptions instance
*/
LocalCachedMapOptions<K, V> 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<K, V> 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<K, V> useKeyEventsPattern(boolean useKeyEventsPattern);
}

@ -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 <K> key type
* @param <V> value type
*/
public final class LocalCachedMapParams<K, V> extends BaseMapOptions<LocalCachedMapOptions<K, V>, K, V> implements LocalCachedMapOptions<K, V> {
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.
* <p>
* If size is <code>0</code> then local cache is unbounded.
* <p>
* If size is <code>-1</code> then local cache is always empty and doesn't store data.
*
* @param cacheSize size of cache
* @return LocalCachedMapOptions instance
*/
public LocalCachedMapParams<K, V> 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
* <p><code>CLEAR</code> - clear local cache if map instance has been disconnected for a while.
* <p><code>LOAD</code> - 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
* <p><code>NONE</code> - Default. No reconnection handling
* @return LocalCachedMapOptions instance
*/
public LocalCachedMapParams<K, V> 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
* <p><code>INVALIDATE</code> - Default. Invalidate cache entry across all LocalCachedMap instances on map entry change
* <p><code>UPDATE</code> - Insert/update cache entry across all LocalCachedMap instances on map entry change
* <p><code>NONE</code> - No synchronizations on map changes
* @return LocalCachedMapOptions instance
*/
public LocalCachedMapParams<K, V> 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
* <p><code>LRU</code> - uses local cache with LRU (least recently used) eviction policy.
* <p><code>LFU</code> - uses local cache with LFU (least frequently used) eviction policy.
* <p><code>SOFT</code> - uses local cache with soft references. The garbage collector will evict items from the local cache when the JVM is running out of memory.
* <p><code>WEAK</code> - uses local cache with weak references. The garbage collector will evict items from the local cache when it became weakly reachable.
* <p><code>NONE</code> - doesn't use eviction policy, but timeToLive and maxIdleTime params are still working.
* @return LocalCachedMapOptions instance
*/
public LocalCachedMapParams<K, V> 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 <code>0</code> then timeout is not applied
*
* @param ttl time to live in milliseconds
* @return LocalCachedMapOptions instance
*/
public LocalCachedMapParams<K, V> 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 <code>0</code> then timeout is not applied
*
* @param idleTime time to live in milliseconds
* @return LocalCachedMapOptions instance
*/
public LocalCachedMapParams<K, V> maxIdle(Duration idleTime) {
this.maxIdleInMillis = idleTime.toMillis();
return this;
}
public StoreMode getStoreMode() {
return storeMode;
}
/**
* Defines store mode of cache data.
*
* @param storeMode
* <p><code>LOCALCACHE</code> - store data in local cache only.
* <p><code>LOCALCACHE_REDIS</code> - store data in both Redis and local cache.
* @return LocalCachedMapOptions instance
*/
public LocalCachedMapParams<K, V> storeMode(StoreMode storeMode) {
this.storeMode = storeMode;
return this;
}
/**
* Defines Cache provider used as local cache store.
*
* @param cacheProvider
* <p><code>REDISSON</code> - uses Redisson own implementation.
* <p><code>CAFFEINE</code> - uses Caffeine implementation.
* @return LocalCachedMapOptions instance
*/
public LocalCachedMapParams<K, V> 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<K, V> 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<K, V> useKeyEventsPattern(boolean useKeyEventsPattern) {
this.useKeyEventsPattern = useKeyEventsPattern;
return this;
}
public String getName() {
return name;
}
}

@ -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 <K> type of key
* @param <V> type of value
*/
public interface MapCacheOptions<K, V> extends ExMapOptions<MapCacheOptions<K, V>, K, V> {
/**
* Creates options with the name of object instance
*
* @param name of object instance
* @return options instance
*/
static <K, V> MapCacheOptions<K, V> 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<K, V> removeEmptyEvictionTask();
}

@ -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 <K> type of key
* @param <V> type of value
*/
public final class MapCacheParams<K, V> extends BaseMapOptions<MapCacheOptions<K, V>, K, V> implements MapCacheOptions<K, V> {
private final String name;
private boolean removeEmptyEvictionTask;
MapCacheParams(String name) {
this.name = name;
}
public String getName() {
return name;
}
@Override
public MapCacheOptions<K, V> removeEmptyEvictionTask() {
removeEmptyEvictionTask = true;
return this;
}
public boolean isRemoveEmptyEvictionTask() {
return removeEmptyEvictionTask;
}
}

@ -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 <K>
* @param <V>
*/
public interface MapOptions<K, V> extends ExMapOptions<MapOptions<K, V>, K, V> {
/**
* Creates options with the name of object instance
*
* @param name of object instance
* @return options instance
*/
static <K, V> MapOptions<K, V> name(String name) {
return new MapParams<>(name);
}
}

@ -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 <K>
* @param <V>
*/
public final class MapParams<K, V> extends BaseMapOptions<MapOptions<K, V>, K, V> implements MapOptions<K, V> {
private final String name;
MapParams(String name) {
this.name = name;
}
public String getName() {
return name;
}
}

@ -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();
}

@ -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<OptionalOptions, Codec> {
/**
* Creates the default options
*
* @return options instance
*/
static OptionalOptions defaults() {
return new OptionalParams();
}
}

@ -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<OptionalOptions, Codec> implements OptionalOptions {
OptionalParams() {
}
}

@ -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<PatternTopicOptions, Codec> {
/**
* 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);
}
}

@ -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<PatternTopicOptions, Codec> implements PatternTopicOptions {
private final String pattern;
PatternTopicParams(String pattern) {
this.pattern = pattern;
}
public String getPattern() {
return pattern;
}
}

@ -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<PlainOptions, Codec> {
/**
* 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);
}
}

@ -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<PlainOptions, Codec> implements PlainOptions {
private final String name;
PlainParams(String name) {
this.name = name;
}
public String getName() {
return name;
}
}

@ -53,24 +53,37 @@ public class BaseRedisBatchExecutor<V, R> extends RedisExecutor<V, R> {
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) {

@ -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<T, R> 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<R> mainPromise = createPromise();
RedisExecutor<V, R> 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<R> result = new CompletableFuture<>();
mainPromise.whenComplete((r, e) -> {
@ -560,7 +595,8 @@ public class CommandAsyncService implements CommandAsyncExecutor {
CompletableFuture<R> mainPromise = createPromise();
RedisExecutor<V, R> 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);
}

@ -56,23 +56,36 @@ public class RedisCommonBatchExecutor extends RedisExecutor<Object, Void> {
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

@ -73,6 +73,9 @@ public class RedisExecutor<V, R> {
final ConnectionManager connectionManager;
final RedissonObjectBuilder.ReferenceType referenceType;
final boolean noRetry;
final int attempts;
final int retryInterval;
final int responseTimeout;
CompletableFuture<RedisConnection> connectionFuture;
NodeSource source;
@ -84,14 +87,11 @@ public class RedisExecutor<V, R> {
volatile ChannelFuture writeFuture;
volatile RedisException exception;
int attempts;
long retryInterval;
long responseTimeout;
public RedisExecutor(boolean readOnlyMode, NodeSource source, Codec codec, RedisCommand<V> command,
Object[] params, CompletableFuture<R> 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<V, R> {
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;
}

@ -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;
}
}

@ -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 <R> Mono<R> reactive(Callable<RFuture<R>> supplier) {
return Flux.<R>create(emitter -> {

@ -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;

@ -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 <R> Flowable<R> flowable(Callable<RFuture<R>> supplier) {
ReplayProcessor<R> p = ReplayProcessor.create();

@ -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<String> al = r.getBucket("test");
al.set(val);
});
RBucket<String> al = r.getBucket(PlainOptions.name("test")
.timeout(Duration.ofSeconds(1)));
al.set(val);
r.shutdown();
}
@Test
public void testGetAndClearExpire() {
RBucket<Integer> al = redisson.getBucket("test");

Loading…
Cancel
Save