org.redisson.rx.RedissonBatchRx 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.rx;
import io.reactivex.rxjava3.core.Completable;
import io.reactivex.rxjava3.core.Maybe;
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;
/**
*
* @author Nikita Koksharov
*
*/
public class RedissonBatchRx implements RBatchRx {
private final EvictionScheduler evictionScheduler;
private final CommandRxBatchService executorService;
private final CommandRxExecutor commandExecutor;
public RedissonBatchRx(EvictionScheduler evictionScheduler, ConnectionManager connectionManager, CommandRxExecutor commandExecutor, BatchOptions options) {
this.evictionScheduler = evictionScheduler;
this.executorService = new CommandRxBatchService(connectionManager, commandExecutor, options);
this.commandExecutor = commandExecutor;
}
@Override
public RStreamRx getStream(String name) {
return RxProxyBuilder.create(executorService, new RedissonStream(executorService, name), RStreamRx.class);
}
@Override
public RStreamRx getStream(String name, Codec codec) {
return RxProxyBuilder.create(executorService, new RedissonStream(codec, executorService, name), RStreamRx.class);
}
@Override
public RBucketRx getBucket(String name) {
return RxProxyBuilder.create(executorService, new RedissonBucket(executorService, name), RBucketRx.class);
}
@Override
public RBucketRx getBucket(String name, Codec codec) {
return RxProxyBuilder.create(executorService, new RedissonBucket(codec, executorService, name), RBucketRx.class);
}
@Override
public RJsonBucketRx getJsonBucket(String name, JsonCodec codec) {
return RxProxyBuilder.create(executorService, new RedissonJsonBucket(codec, executorService, name), RJsonBucketRx.class);
}
@Override
public RHyperLogLogRx getHyperLogLog(String name) {
return RxProxyBuilder.create(executorService, new RedissonHyperLogLog(executorService, name), RHyperLogLogRx.class);
}
@Override
public RHyperLogLogRx getHyperLogLog(String name, Codec codec) {
return RxProxyBuilder.create(executorService, new RedissonHyperLogLog(codec, executorService, name), RHyperLogLogRx.class);
}
@Override
public RListRx getList(String name) {
RedissonList list = new RedissonList(executorService, name, null);
return RxProxyBuilder.create(executorService, list,
new RedissonListRx(list), RListRx.class);
}
@Override
public RListRx getList(String name, Codec codec) {
RedissonList list = new RedissonList(codec, executorService, name, null);
return RxProxyBuilder.create(executorService, list,
new RedissonListRx(list), RListRx.class);
}
@Override
public RMapRx getMap(String name) {
RedissonMap map = new RedissonMap(executorService, name, null, null, null);
return RxProxyBuilder.create(executorService, map,
new RedissonMapRx(map, null), RMapRx.class);
}
@Override
public RMapRx getMap(String name, Codec codec) {
RedissonMap map = new RedissonMap(codec, executorService, name, null, null, null);
return RxProxyBuilder.create(executorService, map,
new RedissonMapRx(map, null), RMapRx.class);
}
@Override
public RMapCacheRx getMapCache(String name, Codec codec) {
RMapCache map = new RedissonMapCache(codec, evictionScheduler, executorService, name, null, null, null);
return RxProxyBuilder.create(executorService, map,
new RedissonMapCacheRx<>(map, commandExecutor), RMapCacheRx.class);
}
@Override
public RMapCacheRx getMapCache(String name) {
RMapCache map = new RedissonMapCache(evictionScheduler, executorService, name, null, null, null);
return RxProxyBuilder.create(executorService, map,
new RedissonMapCacheRx<>(map, commandExecutor), RMapCacheRx.class);
}
@Override
public RMapCacheNativeRx getMapCacheNative(String name) {
RMap map = new RedissonMapCacheNative<>(executorService, name, null, null, null);
return RxProxyBuilder.create(executorService, map,
new RedissonMapCacheRx<>(map, commandExecutor), RMapCacheNativeRx.class);
}
@Override
public RMapCacheNativeRx getMapCacheNative(String name, Codec codec) {
RMap map = new RedissonMapCacheNative<>(codec, executorService, name, null, null, null);
return RxProxyBuilder.create(executorService, map,
new RedissonMapCacheRx<>(map, commandExecutor), RMapCacheNativeRx.class);
}
@Override
public RListMultimapCacheRx getListMultimapCacheNative(String name) {
RListMultimap listMultimap = new RedissonListMultimapCacheNative<>(executorService, name);
return RxProxyBuilder.create(executorService, listMultimap,
new RedissonListMultimapRx(listMultimap, executorService), RListMultimapCacheRx.class);
}
@Override
public RListMultimapCacheRx getListMultimapCacheNative(String name, Codec codec) {
RListMultimap listMultimap = new RedissonListMultimapCacheNative<>(codec, executorService, name);
return RxProxyBuilder.create(executorService, listMultimap,
new RedissonListMultimapRx(listMultimap, executorService), RListMultimapCacheRx.class);
}
@Override
public RSetMultimapCacheRx getSetMultimapCacheNative(String name) {
RSetMultimap setMultimap = new RedissonSetMultimapCacheNative<>(executorService, name);
return RxProxyBuilder.create(executorService, setMultimap,
new RedissonSetMultimapRx<>(setMultimap, executorService, null), RSetMultimapCacheRx.class);
}
@Override
public RSetMultimapCacheRx getSetMultimapCacheNative(String name, Codec codec) {
RSetMultimap setMultimap = new RedissonSetMultimapCacheNative<>(codec, executorService, name);
return RxProxyBuilder.create(executorService, setMultimap,
new RedissonSetMultimapRx<>(setMultimap, executorService, null), RSetMultimapCacheRx.class);
}
@Override
public RSetRx getSet(String name) {
RedissonSet set = new RedissonSet(executorService, name, null);
return RxProxyBuilder.create(executorService, set,
new RedissonSetRx(set, null), RSetRx.class);
}
@Override
public RSetRx getSet(String name, Codec codec) {
RedissonSet set = new RedissonSet(codec, executorService, name, null);
return RxProxyBuilder.create(executorService, set,
new RedissonSetRx(set, null), RSetRx.class);
}
@Override
public RTopicRx getTopic(String name) {
return RxProxyBuilder.create(executorService, new RedissonTopic(executorService, name), RTopicRx.class);
}
@Override
public RTopicRx getTopic(String name, Codec codec) {
return RxProxyBuilder.create(executorService, new RedissonTopic(codec, executorService, name), RTopicRx.class);
}
@Override
public RShardedTopicRx getShardedTopic(String name) {
return RxProxyBuilder.create(executorService, new RedissonShardedTopic(executorService, name), RShardedTopicRx.class);
}
@Override
public RShardedTopicRx getShardedTopic(String name, Codec codec) {
return RxProxyBuilder.create(executorService, new RedissonShardedTopic(codec, executorService, name), RShardedTopicRx.class);
}
@Override
public RQueueRx getQueue(String name) {
RedissonQueue queue = new RedissonQueue(executorService, name, null);
return RxProxyBuilder.create(executorService, queue,
new RedissonListRx(queue), RQueueRx.class);
}
@Override
public RQueueRx getQueue(String name, Codec codec) {
RedissonQueue queue = new RedissonQueue(codec, executorService, name, null);
return RxProxyBuilder.create(executorService, queue,
new RedissonListRx(queue), RQueueRx.class);
}
@Override
public RBlockingQueueRx getBlockingQueue(String name) {
RedissonBlockingQueue queue = new RedissonBlockingQueue(executorService, name, null);
return RxProxyBuilder.create(executorService, queue,
new RedissonListRx(queue), RBlockingQueueRx.class);
}
@Override
public RBlockingQueueRx getBlockingQueue(String name, Codec codec) {
RedissonBlockingQueue queue = new RedissonBlockingQueue(codec, executorService, name, null);
return RxProxyBuilder.create(executorService, queue,
new RedissonListRx(queue), RBlockingQueueRx.class);
}
@Override
public RDequeRx getDeque(String name) {
RedissonDeque deque = new RedissonDeque(executorService, name, null);
return RxProxyBuilder.create(executorService, deque,
new RedissonListRx(deque), RDequeRx.class);
}
@Override
public RDequeRx getDeque(String name, Codec codec) {
RedissonDeque deque = new RedissonDeque(codec, executorService, name, null);
return RxProxyBuilder.create(executorService, deque,
new RedissonListRx(deque), RDequeRx.class);
}
@Override
public RAtomicLongRx getAtomicLong(String name) {
return RxProxyBuilder.create(executorService, new RedissonAtomicLong(executorService, name), RAtomicLongRx.class);
}
@Override
public RSetCacheRx getSetCache(String name) {
RSetCache set = new RedissonSetCache(evictionScheduler, executorService, name, null);
return RxProxyBuilder.create(executorService, set,
new RedissonSetCacheRx(set, null), RSetCacheRx.class);
}
@Override
public RSetCacheRx getSetCache(String name, Codec codec) {
RSetCache set = new RedissonSetCache(codec, evictionScheduler, executorService, name, null);
return RxProxyBuilder.create(executorService, set,
new RedissonSetCacheRx(set, null), RSetCacheRx.class);
}
@Override
public RScoredSortedSetRx getScoredSortedSet(String name) {
RedissonScoredSortedSet set = new RedissonScoredSortedSet(executorService, name, null);
return RxProxyBuilder.create(executorService, set,
new RedissonScoredSortedSetRx(set), RScoredSortedSetRx.class);
}
@Override
public RScoredSortedSetRx getScoredSortedSet(String name, Codec codec) {
RedissonScoredSortedSet set = new RedissonScoredSortedSet(codec, executorService, name, null);
return RxProxyBuilder.create(executorService, set,
new RedissonScoredSortedSetRx(set), RScoredSortedSetRx.class);
}
@Override
public RLexSortedSetRx getLexSortedSet(String name) {
RedissonLexSortedSet set = new RedissonLexSortedSet(executorService, name, null);
return RxProxyBuilder.create(executorService, set,
new RedissonLexSortedSetRx(set),
RLexSortedSetRx.class);
}
@Override
public RBitSetRx getBitSet(String name) {
return RxProxyBuilder.create(executorService, new RedissonBitSet(executorService, name), RBitSetRx.class);
}
@Override
public RScriptRx getScript() {
return RxProxyBuilder.create(executorService, new RedissonScript(executorService), RScriptRx.class);
}
@Override
public RScriptRx getScript(Codec codec) {
return RxProxyBuilder.create(executorService, new RedissonScript(executorService, codec), RScriptRx.class);
}
@Override
public RFunctionRx getFunction() {
return RxProxyBuilder.create(executorService, new RedissonFuction(executorService), RFunctionRx.class);
}
@Override
public RFunctionRx getFunction(Codec codec) {
return RxProxyBuilder.create(executorService, new RedissonFuction(executorService, codec), RFunctionRx.class);
}
@Override
public RKeysRx getKeys() {
return RxProxyBuilder.create(executorService, new RedissonKeys(executorService), new RedissonKeysRx(executorService), RKeysRx.class);
}
@Override
public RSearchRx getSearch() {
return RxProxyBuilder.create(executorService, new RedissonSearch(executorService), RSearchRx.class);
}
@Override
public RSearchRx getSearch(Codec codec) {
return RxProxyBuilder.create(executorService, new RedissonSearch(codec, executorService), RSearchRx.class);
}
@Override
public Maybe> execute() {
return commandExecutor.flowable(() -> executorService.executeAsync()).singleElement();
}
@Override
public Completable discard() {
return commandExecutor.flowable(() -> executorService.discardAsync()).ignoreElements();
}
@Override
public RGeoRx getGeo(String name) {
RedissonGeo geo = new RedissonGeo(executorService, name, null);
return RxProxyBuilder.create(executorService, geo,
new RedissonScoredSortedSetRx(geo), RGeoRx.class);
}
@Override
public RGeoRx getGeo(String name, Codec codec) {
RedissonGeo geo = new RedissonGeo(codec, executorService, name, null);
return RxProxyBuilder.create(executorService, geo,
new RedissonScoredSortedSetRx(geo), RGeoRx.class);
}
@Override
public RSetMultimapRx getSetMultimap(String name) {
RedissonSetMultimap setMultimap = new RedissonSetMultimap<>(executorService, name);
return RxProxyBuilder.create(executorService, setMultimap,
new RedissonSetMultimapRx(setMultimap, executorService, null), RSetMultimapRx.class);
}
@Override
public RSetMultimapRx getSetMultimap(String name, Codec codec) {
RedissonSetMultimap setMultimap = new RedissonSetMultimap<>(codec, executorService, name);
return RxProxyBuilder.create(executorService, setMultimap,
new RedissonSetMultimapRx(setMultimap, executorService, null), RSetMultimapRx.class);
}
@Override
public RSetMultimapCacheRx getSetMultimapCache(String name) {
RSetMultimap setMultimap = new RedissonSetMultimapCache<>(evictionScheduler, executorService, name);
return RxProxyBuilder.create(executorService, setMultimap,
new RedissonSetMultimapRx(setMultimap, executorService, null), RSetMultimapCacheRx.class);
}
@Override
public RSetMultimapCacheRx getSetMultimapCache(String name, Codec codec) {
RSetMultimap setMultimap = new RedissonSetMultimapCache<>(evictionScheduler, codec, executorService, name);
return RxProxyBuilder.create(executorService, setMultimap,
new RedissonSetMultimapRx(setMultimap, executorService, null), RSetMultimapCacheRx.class);
}
@Override
public RListMultimapRx getListMultimap(String name) {
RedissonListMultimap listMultimap = new RedissonListMultimap<>(executorService, name);
return RxProxyBuilder.create(executorService, listMultimap,
new RedissonListMultimapRx(listMultimap, executorService), RListMultimapRx.class);
}
@Override
public RListMultimapRx getListMultimap(String name, Codec codec) {
RedissonListMultimap listMultimap = new RedissonListMultimap<>(codec, executorService, name);
return RxProxyBuilder.create(executorService, listMultimap,
new RedissonListMultimapRx(listMultimap, executorService), RListMultimapRx.class);
}
@Override
public RListMultimapCacheRx getListMultimapCache(String name) {
RedissonListMultimapCache listMultimap = new RedissonListMultimapCache<>(evictionScheduler, executorService, name);
return RxProxyBuilder.create(executorService, listMultimap,
new RedissonListMultimapRx(listMultimap, executorService), RListMultimapCacheRx.class);
}
@Override
public RListMultimapCacheRx getListMultimapCache(String name, Codec codec) {
RedissonListMultimapCache listMultimap = new RedissonListMultimapCache<>(evictionScheduler, codec, executorService, name);
return RxProxyBuilder.create(executorService, listMultimap,
new RedissonListMultimapRx(listMultimap, executorService), RListMultimapCacheRx.class);
}
@Override
public RAtomicDoubleRx getAtomicDouble(String name) {
return RxProxyBuilder.create(executorService, new RedissonAtomicDouble(executorService, name), RAtomicDoubleRx.class);
}
@Override
public RBlockingDequeRx getBlockingDeque(String name) {
RedissonBlockingDeque deque = new RedissonBlockingDeque(executorService, name, null);
return RxProxyBuilder.create(executorService, deque,
new RedissonListRx(deque), RBlockingDequeRx.class);
}
@Override
public RBlockingDequeRx getBlockingDeque(String name, Codec codec) {
RedissonBlockingDeque deque = new RedissonBlockingDeque(codec, executorService, name, null);
return RxProxyBuilder.create(executorService, deque,
new RedissonListRx(deque), RBlockingDequeRx.class);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy