org.redisson.reactive.RedissonBatchReactive Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of redisson-all Show documentation
Show all versions of redisson-all Show documentation
Easy Redis Java client and Real-Time Data Platform. Valkey compatible. Sync/Async/RxJava3/Reactive API. Client side caching. Over 50 Redis based Java objects and services: JCache API, Apache Tomcat, Hibernate, Spring, Set, Multimap, SortedSet, Map, List, Queue, Deque, Semaphore, Lock, AtomicLong, Map Reduce, Bloom filter, Scheduler, RPC
/**
* Copyright (c) 2013-2024 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.reactive;
import org.redisson.*;
import org.redisson.api.*;
import org.redisson.client.codec.Codec;
import org.redisson.codec.JsonCodec;
import org.redisson.connection.ConnectionManager;
import org.redisson.eviction.EvictionScheduler;
import reactor.core.publisher.Mono;
/**
*
* @author Nikita Koksharov
*
*/
public class RedissonBatchReactive implements RBatchReactive {
private final EvictionScheduler evictionScheduler;
private final CommandReactiveBatchService executorService;
private final CommandReactiveExecutor commandExecutor;
public RedissonBatchReactive(EvictionScheduler evictionScheduler, ConnectionManager connectionManager, CommandReactiveExecutor commandExecutor, BatchOptions options) {
this.evictionScheduler = evictionScheduler;
this.executorService = new CommandReactiveBatchService(connectionManager, commandExecutor, options);
this.commandExecutor = commandExecutor;
}
@Override
public RStreamReactive getStream(String name) {
return ReactiveProxyBuilder.create(executorService, new RedissonStream(executorService, name), RStreamReactive.class);
}
@Override
public RStreamReactive getStream(String name, Codec codec) {
return ReactiveProxyBuilder.create(executorService, new RedissonStream(codec, executorService, name), RStreamReactive.class);
}
@Override
public RBucketReactive getBucket(String name) {
return ReactiveProxyBuilder.create(executorService, new RedissonBucket(executorService, name), RBucketReactive.class);
}
@Override
public RBucketReactive getBucket(String name, Codec codec) {
return ReactiveProxyBuilder.create(executorService, new RedissonBucket(codec, executorService, name), RBucketReactive.class);
}
@Override
public RJsonBucketReactive getJsonBucket(String name, JsonCodec codec) {
return ReactiveProxyBuilder.create(executorService, new RedissonJsonBucket<>(codec, executorService, name), RJsonBucketReactive.class);
}
@Override
public RHyperLogLogReactive getHyperLogLog(String name) {
return ReactiveProxyBuilder.create(executorService, new RedissonHyperLogLog(executorService, name), RHyperLogLogReactive.class);
}
@Override
public RHyperLogLogReactive getHyperLogLog(String name, Codec codec) {
return ReactiveProxyBuilder.create(executorService, new RedissonHyperLogLog(codec, executorService, name), RHyperLogLogReactive.class);
}
@Override
public RListReactive getList(String name) {
return ReactiveProxyBuilder.create(executorService, new RedissonList(executorService, name, null),
new RedissonListReactive(executorService, name), RListReactive.class);
}
@Override
public RListReactive getList(String name, Codec codec) {
return ReactiveProxyBuilder.create(executorService, new RedissonList(codec, executorService, name, null),
new RedissonListReactive(codec, executorService, name), RListReactive.class);
}
@Override
public RMapReactive getMap(String name) {
RMap map = new RedissonMap(executorService, name, null, null, null);
return ReactiveProxyBuilder.create(executorService, map,
new RedissonMapReactive<>(map, executorService), RMapReactive.class);
}
@Override
public RMapReactive getMap(String name, Codec codec) {
RedissonMap map = new RedissonMap<>(codec, executorService, name, null, null, null);
return ReactiveProxyBuilder.create(executorService, map,
new RedissonMapReactive<>(map, executorService), RMapReactive.class);
}
@Override
public RMapCacheReactive getMapCache(String name, Codec codec) {
RMapCache map = new RedissonMapCache(codec, evictionScheduler, executorService, name, null, null, null);
return ReactiveProxyBuilder.create(executorService, map,
new RedissonMapCacheReactive(map, commandExecutor), RMapCacheReactive.class);
}
@Override
public RMapCacheReactive getMapCache(String name) {
RMapCache map = new RedissonMapCache(evictionScheduler, executorService, name, null, null, null);
return ReactiveProxyBuilder.create(executorService, map,
new RedissonMapCacheReactive(map, commandExecutor), RMapCacheReactive.class);
}
@Override
public RMapCacheNativeReactive getMapCacheNative(String name) {
RMap map = new RedissonMapCacheNative<>(executorService, name, null, null, null);
return ReactiveProxyBuilder.create(executorService, map,
new RedissonMapCacheReactive(map, commandExecutor), RMapCacheNativeReactive.class);
}
@Override
public RMapCacheNativeReactive getMapCacheNative(String name, Codec codec) {
RMap map = new RedissonMapCacheNative<>(codec, executorService, name, null, null, null);
return ReactiveProxyBuilder.create(executorService, map,
new RedissonMapCacheReactive(map, commandExecutor), RMapCacheNativeReactive.class);
}
@Override
public RListMultimapCacheReactive getListMultimapCacheNative(String name) {
RListMultimap map = new RedissonListMultimapCacheNative<>(executorService, name);
return ReactiveProxyBuilder.create(executorService, map,
new RedissonListMultimapCacheReactive<>(map, executorService), RListMultimapCacheReactive.class);
}
@Override
public RListMultimapCacheReactive getListMultimapCacheNative(String name, Codec codec) {
RListMultimap map = new RedissonListMultimapCacheNative<>(codec, executorService, name);
return ReactiveProxyBuilder.create(executorService, map,
new RedissonListMultimapCacheReactive<>(map, executorService), RListMultimapCacheReactive.class);
}
@Override
public RSetMultimapCacheReactive getSetMultimapCacheNative(String name) {
RSetMultimap map = new RedissonSetMultimapCacheNative<>(executorService, name);
return ReactiveProxyBuilder.create(executorService, map,
new RedissonSetMultimapCacheReactive<>(map, executorService, null), RSetMultimapCacheReactive.class);
}
@Override
public RSetMultimapCacheReactive getSetMultimapCacheNative(String name, Codec codec) {
RSetMultimap map = new RedissonSetMultimapCacheNative<>(codec, executorService, name);
return ReactiveProxyBuilder.create(executorService, map,
new RedissonSetMultimapCacheReactive<>(map, executorService, null), RSetMultimapCacheReactive.class);
}
@Override
public RSetReactive getSet(String name) {
RedissonSet set = new RedissonSet(executorService, name, null);
return ReactiveProxyBuilder.create(executorService, set,
new RedissonSetReactive(set, null), RSetReactive.class);
}
@Override
public RSetReactive getSet(String name, Codec codec) {
RedissonSet set = new RedissonSet(codec, executorService, name, null);
return ReactiveProxyBuilder.create(executorService, set,
new RedissonSetReactive(set, null), RSetReactive.class);
}
@Override
public RTopicReactive getTopic(String name) {
return ReactiveProxyBuilder.create(executorService, new RedissonTopic(executorService, name), RTopicReactive.class);
}
@Override
public RTopicReactive getTopic(String name, Codec codec) {
return ReactiveProxyBuilder.create(executorService, new RedissonTopic(codec, executorService, name), RTopicReactive.class);
}
@Override
public RShardedTopicReactive getShardedTopic(String name) {
return ReactiveProxyBuilder.create(executorService, new RedissonShardedTopic(executorService, name), RShardedTopicReactive.class);
}
@Override
public RShardedTopicReactive getShardedTopic(String name, Codec codec) {
return ReactiveProxyBuilder.create(executorService, new RedissonShardedTopic(codec, executorService, name), RShardedTopicReactive.class);
}
@Override
public RQueueReactive getQueue(String name) {
return ReactiveProxyBuilder.create(executorService, new RedissonQueue(executorService, name, null),
new RedissonListReactive(executorService, name), RQueueReactive.class);
}
@Override
public RQueueReactive getQueue(String name, Codec codec) {
return ReactiveProxyBuilder.create(executorService, new RedissonQueue(codec, executorService, name, null),
new RedissonListReactive(codec, executorService, name), RQueueReactive.class);
}
@Override
public RBlockingQueueReactive getBlockingQueue(String name) {
return ReactiveProxyBuilder.create(executorService, new RedissonBlockingQueue(executorService, name, null),
new RedissonListReactive(executorService, name), RBlockingQueueReactive.class);
}
@Override
public RBlockingQueueReactive getBlockingQueue(String name, Codec codec) {
return ReactiveProxyBuilder.create(executorService, new RedissonBlockingQueue(codec, executorService, name, null),
new RedissonListReactive(codec, executorService, name), RBlockingQueueReactive.class);
}
@Override
public RDequeReactive getDeque(String name) {
return ReactiveProxyBuilder.create(executorService, new RedissonDeque(executorService, name, null),
new RedissonListReactive(executorService, name), RDequeReactive.class);
}
@Override
public RDequeReactive getDeque(String name, Codec codec) {
return ReactiveProxyBuilder.create(executorService, new RedissonDeque(codec, executorService, name, null),
new RedissonListReactive(codec, executorService, name), RDequeReactive.class);
}
@Override
public RAtomicLongReactive getAtomicLong(String name) {
return ReactiveProxyBuilder.create(executorService, new RedissonAtomicLong(executorService, name), RAtomicLongReactive.class);
}
@Override
public RSetCacheReactive getSetCache(String name) {
RSetCache set = new RedissonSetCache(evictionScheduler, executorService, name, null);
return ReactiveProxyBuilder.create(executorService, set,
new RedissonSetCacheReactive(set, null), RSetCacheReactive.class);
}
@Override
public RSetCacheReactive getSetCache(String name, Codec codec) {
RSetCache set = new RedissonSetCache(codec, evictionScheduler, executorService, name, null);
return ReactiveProxyBuilder.create(executorService, set,
new RedissonSetCacheReactive(set, null), RSetCacheReactive.class);
}
@Override
public RScoredSortedSetReactive getScoredSortedSet(String name) {
return ReactiveProxyBuilder.create(executorService, new RedissonScoredSortedSet(executorService, name, null),
new RedissonScoredSortedSetReactive(executorService, name), RScoredSortedSetReactive.class);
}
@Override
public RScoredSortedSetReactive getScoredSortedSet(String name, Codec codec) {
return ReactiveProxyBuilder.create(executorService, new RedissonScoredSortedSet(codec, executorService, name, null),
new RedissonScoredSortedSetReactive(codec, executorService, name), RScoredSortedSetReactive.class);
}
@Override
public RLexSortedSetReactive getLexSortedSet(String name) {
RedissonLexSortedSet set = new RedissonLexSortedSet(executorService, name, null);
return ReactiveProxyBuilder.create(executorService, set,
new RedissonLexSortedSetReactive(set),
RLexSortedSetReactive.class);
}
@Override
public RBitSetReactive getBitSet(String name) {
return ReactiveProxyBuilder.create(executorService, new RedissonBitSet(executorService, name), RBitSetReactive.class);
}
@Override
public RScriptReactive getScript() {
return ReactiveProxyBuilder.create(executorService, new RedissonScript(executorService), RScriptReactive.class);
}
@Override
public RScriptReactive getScript(Codec codec) {
return ReactiveProxyBuilder.create(executorService, new RedissonScript(executorService, codec), RScriptReactive.class);
}
@Override
public RFunctionReactive getFunction() {
return ReactiveProxyBuilder.create(executorService, new RedissonFuction(executorService), RFunctionReactive.class);
}
@Override
public RFunctionReactive getFunction(Codec codec) {
return ReactiveProxyBuilder.create(executorService, new RedissonFuction(executorService, codec), RFunctionReactive.class);
}
@Override
public RKeysReactive getKeys() {
return ReactiveProxyBuilder.create(executorService, new RedissonKeys(executorService), new RedissonKeysReactive(executorService), RKeysReactive.class);
}
@Override
public RSearchReactive getSearch() {
return ReactiveProxyBuilder.create(executorService, new RedissonSearch(executorService), RSearchReactive.class);
}
@Override
public RSearchReactive getSearch(Codec codec) {
return ReactiveProxyBuilder.create(executorService, new RedissonSearch(codec, executorService), RSearchReactive.class);
}
@Override
public Mono> execute() {
return commandExecutor.reactive(() -> executorService.executeAsync());
}
@Override
public Mono discard() {
return commandExecutor.reactive(() -> executorService.discardAsync());
}
@Override
public RGeoReactive getGeo(String name) {
return ReactiveProxyBuilder.create(executorService, new RedissonGeo(executorService, name, null),
new RedissonScoredSortedSetReactive(executorService, name), RGeoReactive.class);
}
@Override
public RGeoReactive getGeo(String name, Codec codec) {
return ReactiveProxyBuilder.create(executorService, new RedissonGeo(codec, executorService, name, null),
new RedissonScoredSortedSetReactive(codec, executorService, name), RGeoReactive.class);
}
@Override
public RSetMultimapReactive getSetMultimap(String name) {
return ReactiveProxyBuilder.create(executorService, new RedissonSetMultimap(executorService, name),
new RedissonSetMultimapReactive(executorService, name, null), RSetMultimapReactive.class);
}
@Override
public RSetMultimapReactive getSetMultimap(String name, Codec codec) {
return ReactiveProxyBuilder.create(executorService, new RedissonSetMultimap(codec, executorService, name),
new RedissonSetMultimapReactive(codec, executorService, name, null), RSetMultimapReactive.class);
}
@Override
public RSetMultimapCacheReactive getSetMultimapCache(String name) {
RSetMultimap map = new RedissonSetMultimapCache<>(evictionScheduler, executorService, name);
return ReactiveProxyBuilder.create(executorService, map,
new RedissonSetMultimapCacheReactive<>(map, executorService, null), RSetMultimapCacheReactive.class);
}
@Override
public RSetMultimapCacheReactive getSetMultimapCache(String name, Codec codec) {
RSetMultimap map = new RedissonSetMultimapCache<>(evictionScheduler, codec, executorService, name);
return ReactiveProxyBuilder.create(executorService, map,
new RedissonSetMultimapCacheReactive<>(map, executorService, null), RSetMultimapCacheReactive.class);
}
@Override
public RListMultimapReactive getListMultimap(String name) {
return ReactiveProxyBuilder.create(executorService, new RedissonListMultimap(executorService, name),
new RedissonListMultimapReactive(executorService, name), RListMultimapReactive.class);
}
@Override
public RListMultimapReactive getListMultimap(String name, Codec codec) {
return ReactiveProxyBuilder.create(executorService, new RedissonListMultimap(codec, executorService, name),
new RedissonListMultimapReactive(codec, executorService, name), RListMultimapReactive.class);
}
@Override
public RListMultimapReactive getListMultimapCache(String name) {
RListMultimap map = new RedissonListMultimapCache<>(evictionScheduler, executorService, name);
return ReactiveProxyBuilder.create(executorService, map,
new RedissonListMultimapCacheReactive<>(map, executorService), RListMultimapReactive.class);
}
@Override
public RListMultimapReactive getListMultimapCache(String name, Codec codec) {
RListMultimap map = new RedissonListMultimapCache<>(evictionScheduler, codec, executorService, name);
return ReactiveProxyBuilder.create(executorService, map,
new RedissonListMultimapCacheReactive<>(map, executorService), RListMultimapReactive.class);
}
@Override
public RAtomicDoubleReactive getAtomicDouble(String name) {
return ReactiveProxyBuilder.create(executorService, new RedissonAtomicDouble(executorService, name), RAtomicDoubleReactive.class);
}
@Override
public RBlockingDequeReactive getBlockingDeque(String name) {
return ReactiveProxyBuilder.create(executorService, new RedissonBlockingDeque(executorService, name, null),
new RedissonListReactive(executorService, name), RBlockingDequeReactive.class);
}
@Override
public RBlockingDequeReactive getBlockingDeque(String name, Codec codec) {
return ReactiveProxyBuilder.create(executorService, new RedissonBlockingDeque(codec, executorService, name, null),
new RedissonListReactive(codec, executorService, name), RBlockingDequeReactive.class);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy