All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.lontime.shaded.org.redisson.RedissonRx Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (c) 2013-2021 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 com.github.lontime.shaded.org.redisson;

import com.github.lontime.shaded.org.redisson.api.*;
import com.github.lontime.shaded.org.redisson.client.codec.Codec;
import com.github.lontime.shaded.org.redisson.codec.JsonCodec;
import com.github.lontime.shaded.org.redisson.config.Config;
import com.github.lontime.shaded.org.redisson.config.ConfigSupport;
import com.github.lontime.shaded.org.redisson.connection.ConnectionManager;
import com.github.lontime.shaded.org.redisson.eviction.EvictionScheduler;
import com.github.lontime.shaded.org.redisson.liveobject.core.RedissonObjectBuilder;
import com.github.lontime.shaded.org.redisson.remote.ResponseEntry;
import com.github.lontime.shaded.org.redisson.rx.*;

import java.util.Arrays;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

/**
 * Main infrastructure class allows to get access
 * to all Redisson objects on top of Redis server.
 *
 * @author Nikita Koksharov
 *
 */
public class RedissonRx implements RedissonRxClient {

    protected final WriteBehindService writeBehindService;
    protected final EvictionScheduler evictionScheduler;
    protected final CommandRxExecutor commandExecutor;
    protected final ConnectionManager connectionManager;
    protected final ConcurrentMap responses;
    
    protected RedissonRx(Config config) {
        Config configCopy = new Config(config);

        connectionManager = ConfigSupport.createConnectionManager(configCopy);
        RedissonObjectBuilder objectBuilder = null;
        if (connectionManager.getCfg().isReferenceEnabled()) {
            objectBuilder = new RedissonObjectBuilder(this);
        }
        commandExecutor = new CommandRxService(connectionManager, objectBuilder);
        evictionScheduler = new EvictionScheduler(commandExecutor);
        writeBehindService = new WriteBehindService(commandExecutor);
        responses = new ConcurrentHashMap<>();
    }

    protected RedissonRx(ConnectionManager connectionManager, EvictionScheduler evictionScheduler,
                         WriteBehindService writeBehindService, ConcurrentMap responses) {
        this.connectionManager = connectionManager;
        RedissonObjectBuilder objectBuilder = null;
        if (connectionManager.getCfg().isReferenceEnabled()) {
            objectBuilder = new RedissonObjectBuilder(this);
        }
        commandExecutor = new CommandRxService(connectionManager, objectBuilder);
        this.evictionScheduler = evictionScheduler;
        this.writeBehindService = writeBehindService;
        this.responses = responses;
    }

    public CommandRxExecutor getCommandExecutor() {
        return commandExecutor;
    }

    @Override
    public  RStreamRx getStream(String name) {
        return RxProxyBuilder.create(commandExecutor, new RedissonStream(commandExecutor, name), RStreamRx.class);
    }

    @Override
    public  RStreamRx getStream(String name, Codec codec) {
        return RxProxyBuilder.create(commandExecutor, new RedissonStream(codec, commandExecutor, name), RStreamRx.class);
    }

    @Override
    public  RGeoRx getGeo(String name) {
        RedissonScoredSortedSet set = new RedissonScoredSortedSet(commandExecutor, name, null);
        return RxProxyBuilder.create(commandExecutor, new RedissonGeo(commandExecutor, name, null), 
                new RedissonScoredSortedSetRx(set), RGeoRx.class);
    }
    
    @Override
    public  RGeoRx getGeo(String name, Codec codec) {
        RedissonScoredSortedSet set = new RedissonScoredSortedSet(codec, commandExecutor, name, null);
        return RxProxyBuilder.create(commandExecutor, new RedissonGeo(codec, commandExecutor, name, null), 
                new RedissonScoredSortedSetRx(set), RGeoRx.class);
    }
    
    @Override
    public RLockRx getFairLock(String name) {
        return RxProxyBuilder.create(commandExecutor, new RedissonFairLock(commandExecutor, name), RLockRx.class);
    }
    
    @Override
    public RRateLimiterRx getRateLimiter(String name) {
        return RxProxyBuilder.create(commandExecutor, new RedissonRateLimiter(commandExecutor, name), RRateLimiterRx.class);
    }
    
    @Override
    public RBinaryStreamRx getBinaryStream(String name) {
        RedissonBinaryStream stream = new RedissonBinaryStream(commandExecutor, name);
        return RxProxyBuilder.create(commandExecutor, stream,
                new RedissonBinaryStreamRx(commandExecutor, stream), RBinaryStreamRx.class);
    }

    @Override
    public RSemaphoreRx getSemaphore(String name) {
        return RxProxyBuilder.create(commandExecutor, new RedissonSemaphore(commandExecutor, name), RSemaphoreRx.class);
    }

    @Override
    public RPermitExpirableSemaphoreRx getPermitExpirableSemaphore(String name) {
        return RxProxyBuilder.create(commandExecutor, new RedissonPermitExpirableSemaphore(commandExecutor, name), RPermitExpirableSemaphoreRx.class);
    }

    @Override
    public RReadWriteLockRx getReadWriteLock(String name) {
        return new RedissonReadWriteLockRx(commandExecutor, name);
    }

    @Override
    public RLockRx getLock(String name) {
        return RxProxyBuilder.create(commandExecutor, new RedissonLock(commandExecutor, name), RLockRx.class);
    }

    @Override
    public RLockRx getSpinLock(String name) {
        return getSpinLock(name, LockOptions.defaults());
    }

    @Override
    public RLockRx getSpinLock(String name, LockOptions.BackOff backOff) {
        RedissonSpinLock spinLock = new RedissonSpinLock(commandExecutor, name, backOff);
        return RxProxyBuilder.create(commandExecutor, spinLock, RLockRx.class);
    }

    @Override
    public RLockRx getMultiLock(RLockRx... locks) {
        RLock[] ls = Arrays.stream(locks)
                            .map(l -> new RedissonLock(commandExecutor, l.getName()))
                            .toArray(RLock[]::new);
        return RxProxyBuilder.create(commandExecutor, new RedissonMultiLock(ls), RLockRx.class);
    }

    @Override
    public RLockRx getMultiLock(RLock... locks) {
        return RxProxyBuilder.create(commandExecutor, new RedissonMultiLock(locks), RLockRx.class);
    }
    
    @Override
    public RLockRx getRedLock(RLock... locks) {
        return RxProxyBuilder.create(commandExecutor, new RedissonRedLock(locks), RLockRx.class);
    }

    @Override
    public RCountDownLatchRx getCountDownLatch(String name) {
        return RxProxyBuilder.create(commandExecutor, new RedissonCountDownLatch(commandExecutor, name), RCountDownLatchRx.class);
    }

    @Override
    public  RMapCacheRx getMapCache(String name, Codec codec) {
        RMap map = new RedissonMapCache(codec, evictionScheduler, commandExecutor, name, null, null, null);
        return RxProxyBuilder.create(commandExecutor, map, 
                new RedissonMapCacheRx(map, commandExecutor), RMapCacheRx.class);
    }

    @Override
    public  RMapCacheRx getMapCache(String name) {
        RedissonMapCache map = new RedissonMapCache(evictionScheduler, commandExecutor, name, null, null, null);
        return RxProxyBuilder.create(commandExecutor, map, 
                new RedissonMapCacheRx(map, commandExecutor), RMapCacheRx.class);
    }

    @Override
    public  RBucketRx getBucket(String name) {
        return RxProxyBuilder.create(commandExecutor, new RedissonBucket(commandExecutor, name), RBucketRx.class);
    }

    @Override
    public  RBucketRx getBucket(String name, Codec codec) {
        return RxProxyBuilder.create(commandExecutor, new RedissonBucket(codec, commandExecutor, name), RBucketRx.class);
    }

    @Override
    public RBucketsRx getBuckets() {
        return RxProxyBuilder.create(commandExecutor, new RedissonBuckets(commandExecutor), RBucketsRx.class);
    }

    @Override
    public RBucketsRx getBuckets(Codec codec) {
        return RxProxyBuilder.create(commandExecutor, new RedissonBuckets(codec, commandExecutor), RBucketsRx.class);
    }

    @Override
    public  RJsonBucketRx getJsonBucket(String name, JsonCodec codec) {
        return RxProxyBuilder.create(commandExecutor, new RedissonJsonBucket<>(codec, commandExecutor, name), RJsonBucketRx.class);
    }

    @Override
    public  RHyperLogLogRx getHyperLogLog(String name) {
        return RxProxyBuilder.create(commandExecutor, new RedissonHyperLogLog(commandExecutor, name), RHyperLogLogRx.class);
    }

    @Override
    public  RHyperLogLogRx getHyperLogLog(String name, Codec codec) {
        return RxProxyBuilder.create(commandExecutor, new RedissonHyperLogLog(codec, commandExecutor, name), RHyperLogLogRx.class);
    }

    @Override
    public RIdGeneratorRx getIdGenerator(String name) {
        return RxProxyBuilder.create(commandExecutor, new RedissonIdGenerator(commandExecutor, name), RIdGeneratorRx.class);
    }

    @Override
    public  RListRx getList(String name) {
        RedissonList list = new RedissonList(commandExecutor, name, null);
        return RxProxyBuilder.create(commandExecutor, list, 
                new RedissonListRx(list), RListRx.class);
    }

    @Override
    public  RListRx getList(String name, Codec codec) {
        RedissonList list = new RedissonList(codec, commandExecutor, name, null);
        return RxProxyBuilder.create(commandExecutor, list, 
                new RedissonListRx(list), RListRx.class);
    }

    @Override
    public  RListMultimapRx getListMultimap(String name) {
        RedissonListMultimap listMultimap = new RedissonListMultimap<>(commandExecutor, name);
        return RxProxyBuilder.create(commandExecutor, listMultimap,
                new RedissonListMultimapRx(listMultimap, commandExecutor), RListMultimapRx.class);
    }

    @Override
    public  RListMultimapRx getListMultimap(String name, Codec codec) {
        RedissonListMultimap listMultimap = new RedissonListMultimap<>(codec, commandExecutor, name);
        return RxProxyBuilder.create(commandExecutor, listMultimap,
                new RedissonListMultimapRx(listMultimap, commandExecutor), RListMultimapRx.class);
    }

    @Override
    public  RListMultimapCacheRx getListMultimapCache(String name) {
        RedissonListMultimapCache listMultimap = new RedissonListMultimapCache<>(evictionScheduler, commandExecutor, name);
        return RxProxyBuilder.create(commandExecutor, listMultimap,
                new RedissonListMultimapCacheRx(listMultimap, commandExecutor), RListMultimapCacheRx.class);
    }

    @Override
    public  RListMultimapCacheRx getListMultimapCache(String name, Codec codec) {
        RedissonListMultimapCache listMultimap = new RedissonListMultimapCache<>(evictionScheduler, codec, commandExecutor, name);
        return RxProxyBuilder.create(commandExecutor, listMultimap,
                new RedissonListMultimapCacheRx(listMultimap, commandExecutor), RListMultimapCacheRx.class);
    }

    @Override
    public  RSetMultimapRx getSetMultimap(String name) {
        RedissonSetMultimap setMultimap = new RedissonSetMultimap<>(commandExecutor, name);
        return RxProxyBuilder.create(commandExecutor, setMultimap,
                new RedissonSetMultimapRx(setMultimap, commandExecutor, this), RSetMultimapRx.class);
    }

    @Override
    public  RSetMultimapRx getSetMultimap(String name, Codec codec) {
        RedissonSetMultimap setMultimap = new RedissonSetMultimap<>(codec, commandExecutor, name);
        return RxProxyBuilder.create(commandExecutor, setMultimap,
                new RedissonSetMultimapRx(setMultimap, commandExecutor, this), RSetMultimapRx.class);
    }

    @Override
    public  RSetMultimapCacheRx getSetMultimapCache(String name) {
        RedissonSetMultimapCache setMultimap = new RedissonSetMultimapCache<>(evictionScheduler, commandExecutor, name);
        return RxProxyBuilder.create(commandExecutor, setMultimap,
                new RedissonSetMultimapCacheRx(setMultimap, commandExecutor, this), RSetMultimapCacheRx.class);
    }

    @Override
    public  RSetMultimapCacheRx getSetMultimapCache(String name, Codec codec) {
        RedissonSetMultimapCache setMultimap = new RedissonSetMultimapCache<>(evictionScheduler, codec, commandExecutor, name);
        return RxProxyBuilder.create(commandExecutor, setMultimap,
                new RedissonSetMultimapCacheRx(setMultimap, commandExecutor, this), RSetMultimapCacheRx.class);
    }

    @Override
    public  RMapRx getMap(String name) {
        RedissonMap map = new RedissonMap(commandExecutor, name, null, null, null);
        return RxProxyBuilder.create(commandExecutor, map, 
                new RedissonMapRx(map, commandExecutor), RMapRx.class);
    }

    @Override
    public  RMapRx getMap(String name, Codec codec) {
        RedissonMap map = new RedissonMap(codec, commandExecutor, name, null, null, null);
        return RxProxyBuilder.create(commandExecutor, map, 
                new RedissonMapRx(map, commandExecutor), RMapRx.class);
    }

    @Override
    public  RSetRx getSet(String name) {
        RedissonSet set = new RedissonSet(commandExecutor, name, null);
        return RxProxyBuilder.create(commandExecutor, set, 
                new RedissonSetRx(set, this), RSetRx.class);
    }

    @Override
    public  RSetRx getSet(String name, Codec codec) {
        RedissonSet set = new RedissonSet(codec, commandExecutor, name, null);
        return RxProxyBuilder.create(commandExecutor, set, 
                new RedissonSetRx(set, this), RSetRx.class);
    }

    @Override
    public  RScoredSortedSetRx getScoredSortedSet(String name) {
        RedissonScoredSortedSet set = new RedissonScoredSortedSet(commandExecutor, name, null);
        return RxProxyBuilder.create(commandExecutor, set, 
                new RedissonScoredSortedSetRx(set), RScoredSortedSetRx.class);
    }

    @Override
    public  RScoredSortedSetRx getScoredSortedSet(String name, Codec codec) {
        RedissonScoredSortedSet set = new RedissonScoredSortedSet(codec, commandExecutor, name, null);
        return RxProxyBuilder.create(commandExecutor, set, 
                new RedissonScoredSortedSetRx(set), RScoredSortedSetRx.class);
    }

    @Override
    public RLexSortedSetRx getLexSortedSet(String name) {
        RedissonLexSortedSet set = new RedissonLexSortedSet(commandExecutor, name, null);
        return RxProxyBuilder.create(commandExecutor, set, 
                new RedissonLexSortedSetRx(set), RLexSortedSetRx.class);
    }

    @Override
    public RShardedTopicRx getShardedTopic(String name) {
        RShardedTopic topic = new RedissonShardedTopic(commandExecutor, name);
        return RxProxyBuilder.create(commandExecutor, topic, new RedissonTopicRx(topic), RShardedTopicRx.class);
    }

    @Override
    public RShardedTopicRx getShardedTopic(String name, Codec codec) {
        RShardedTopic topic = new RedissonShardedTopic(codec, commandExecutor, name);
        return RxProxyBuilder.create(commandExecutor, topic, new RedissonTopicRx(topic), RShardedTopicRx.class);
    }

    @Override
    public RTopicRx getTopic(String name) {
        RTopic topic = new RedissonTopic(commandExecutor, name);
        return RxProxyBuilder.create(commandExecutor, topic, new RedissonTopicRx(topic), RTopicRx.class);
    }

    @Override
    public RTopicRx getTopic(String name, Codec codec) {
        RTopic topic = new RedissonTopic(codec, commandExecutor, name);
        return RxProxyBuilder.create(commandExecutor, topic, new RedissonTopicRx(topic), RTopicRx.class);
    }

    @Override
    public RReliableTopicRx getReliableTopic(String name) {
        return RxProxyBuilder.create(commandExecutor, new RedissonReliableTopic(commandExecutor, name), RReliableTopicRx.class);
    }

    @Override
    public RReliableTopicRx getReliableTopic(String name, Codec codec) {
        return RxProxyBuilder.create(commandExecutor, new RedissonReliableTopic(codec, commandExecutor, name), RReliableTopicRx.class);
    }

    @Override
    public RPatternTopicRx getPatternTopic(String pattern) {
        return RxProxyBuilder.create(commandExecutor, new RedissonPatternTopic(commandExecutor, pattern), RPatternTopicRx.class);
    }

    @Override
    public RPatternTopicRx getPatternTopic(String pattern, Codec codec) {
        return RxProxyBuilder.create(commandExecutor, new RedissonPatternTopic(codec, commandExecutor, pattern), RPatternTopicRx.class);
    }

    @Override
    public  RQueueRx getQueue(String name) {
        return RxProxyBuilder.create(commandExecutor, new RedissonQueue(commandExecutor, name, null), 
                new RedissonListRx(new RedissonList(commandExecutor, name, null)), RQueueRx.class);
    }

    @Override
    public  RQueueRx getQueue(String name, Codec codec) {
        return RxProxyBuilder.create(commandExecutor, new RedissonQueue(codec, commandExecutor, name, null), 
                new RedissonListRx(new RedissonList(codec, commandExecutor, name, null)), RQueueRx.class);
    }

    @Override
    public  RRingBufferRx getRingBuffer(String name) {
        return RxProxyBuilder.create(commandExecutor, new RedissonRingBuffer(commandExecutor, name, null), RRingBufferRx.class);
    }

    @Override
    public  RRingBufferRx getRingBuffer(String name, Codec codec) {
        return RxProxyBuilder.create(commandExecutor, new RedissonRingBuffer(codec, commandExecutor, name, null), RRingBufferRx.class);
    }

    @Override
    public  RBlockingQueueRx getBlockingQueue(String name) {
        RedissonBlockingQueue queue = new RedissonBlockingQueue(commandExecutor, name, null);
        return RxProxyBuilder.create(commandExecutor, queue, 
                new RedissonBlockingQueueRx(queue), RBlockingQueueRx.class);
    }

    @Override
    public  RBlockingQueueRx getBlockingQueue(String name, Codec codec) {
        RedissonBlockingQueue queue = new RedissonBlockingQueue(codec, commandExecutor, name, null);
        return RxProxyBuilder.create(commandExecutor, queue, 
                new RedissonBlockingQueueRx(queue), RBlockingQueueRx.class);
    }

    @Override
    public  RDequeRx getDeque(String name) {
        RedissonDeque queue = new RedissonDeque(commandExecutor, name, null);
        return RxProxyBuilder.create(commandExecutor, queue, 
                new RedissonListRx(queue), RDequeRx.class);
    }

    @Override
    public  RDequeRx getDeque(String name, Codec codec) {
        RedissonDeque queue = new RedissonDeque(codec, commandExecutor, name, null);
        return RxProxyBuilder.create(commandExecutor, queue, 
                new RedissonListRx(queue), RDequeRx.class);
    }

    @Override
    public  RTimeSeriesRx getTimeSeries(String name) {
        RTimeSeries timeSeries = new RedissonTimeSeries(evictionScheduler, commandExecutor, name);
        return RxProxyBuilder.create(commandExecutor, timeSeries,
                new RedissonTimeSeriesRx(timeSeries, this), RTimeSeriesRx.class);
    }

    @Override
    public  RTimeSeriesRx getTimeSeries(String name, Codec codec) {
        RTimeSeries timeSeries = new RedissonTimeSeries(codec, evictionScheduler, commandExecutor, name);
        return RxProxyBuilder.create(commandExecutor, timeSeries,
                new RedissonTimeSeriesRx(timeSeries, this), RTimeSeriesRx.class);
    }

    @Override
    public  RSetCacheRx getSetCache(String name) {
        RSetCache set = new RedissonSetCache(evictionScheduler, commandExecutor, name, null);
        return RxProxyBuilder.create(commandExecutor, set, 
                new RedissonSetCacheRx(set, this), RSetCacheRx.class);
    }

    @Override
    public  RSetCacheRx getSetCache(String name, Codec codec) {
        RSetCache set = new RedissonSetCache(codec, evictionScheduler, commandExecutor, name, null);
        return RxProxyBuilder.create(commandExecutor, set, 
                new RedissonSetCacheRx(set, this), RSetCacheRx.class);
    }

    @Override
    public RAtomicLongRx getAtomicLong(String name) {
        return RxProxyBuilder.create(commandExecutor, new RedissonAtomicLong(commandExecutor, name), RAtomicLongRx.class);
    }

    @Override
    public RAtomicDoubleRx getAtomicDouble(String name) {
        return RxProxyBuilder.create(commandExecutor, new RedissonAtomicDouble(commandExecutor, name), RAtomicDoubleRx.class);
    }
    
    @Override
    public RRemoteService getRemoteService() {
        return getRemoteService("redisson_rs", connectionManager.getCodec());
    }

    @Override
    public RRemoteService getRemoteService(String name) {
        return getRemoteService(name, connectionManager.getCodec());
    }

    @Override
    public RRemoteService getRemoteService(Codec codec) {
        return getRemoteService("redisson_rs", codec);
    }

    @Override
    public RRemoteService getRemoteService(String name, Codec codec) {
        String executorId = connectionManager.getId();
        if (codec != connectionManager.getCodec()) {
            executorId = executorId + ":" + name;
        }
        return new RedissonRemoteService(codec, name, commandExecutor, executorId, responses);
    }

    @Override
    public RBitSetRx getBitSet(String name) {
        return RxProxyBuilder.create(commandExecutor, new RedissonBitSet(commandExecutor, name), RBitSetRx.class);
    }

    @Override
    public RFunctionRx getFunction() {
        return RxProxyBuilder.create(commandExecutor, new RedissonFuction(commandExecutor), RFunctionRx.class);
    }

    @Override
    public RFunctionRx getFunction(Codec codec) {
        return RxProxyBuilder.create(commandExecutor, new RedissonFuction(commandExecutor, codec), RFunctionRx.class);
    }

    @Override
    public RScriptRx getScript() {
        return RxProxyBuilder.create(commandExecutor, new RedissonScript(commandExecutor), RScriptRx.class);
    }
    
    @Override
    public RScriptRx getScript(Codec codec) {
        return RxProxyBuilder.create(commandExecutor, new RedissonScript(commandExecutor, codec), RScriptRx.class);
    }

    @Override
    public RBatchRx createBatch() {
        return createBatch(BatchOptions.defaults());
    }
    
    @Override
    public RBatchRx createBatch(BatchOptions options) {
        return new RedissonBatchRx(evictionScheduler, connectionManager, commandExecutor, options);
    }

    @Override
    public RKeysRx getKeys() {
        return RxProxyBuilder.create(commandExecutor, new RedissonKeys(commandExecutor), new RedissonKeysRx(commandExecutor), RKeysRx.class);
    }

    @Override
    public Config getConfig() {
        return connectionManager.getCfg();
    }

    @Override
    public NodesGroup getNodesGroup() {
        return new RedisNodes(connectionManager, commandExecutor);
    }

    @Override
    public NodesGroup getClusterNodesGroup() {
        if (!connectionManager.isClusterMode()) {
            throw new IllegalStateException("Redisson not in cluster mode!");
        }
        return new RedisNodes(connectionManager, commandExecutor);
    }

    @Override
    public void shutdown() {
        writeBehindService.stop();
        connectionManager.shutdown();
    }

    @Override
    public boolean isShutdown() {
        return connectionManager.isShutdown();
    }

    @Override
    public boolean isShuttingDown() {
        return connectionManager.isShuttingDown();
    }

    @Override
    public  RMapCacheRx getMapCache(String name, Codec codec, MapOptions options) {
        RedissonMapCache map = new RedissonMapCache(codec, evictionScheduler, commandExecutor, name, null, options, writeBehindService);
        return RxProxyBuilder.create(commandExecutor, map, 
                new RedissonMapCacheRx(map, commandExecutor), RMapCacheRx.class);
    }


    @Override
    public  RMapCacheRx getMapCache(String name, MapOptions options) {
        RMap map = new RedissonMapCache(evictionScheduler, commandExecutor, name, null, options, writeBehindService);
        return RxProxyBuilder.create(commandExecutor, map, 
                new RedissonMapCacheRx(map, commandExecutor), RMapCacheRx.class);
    }

    @Override
    public  RMapRx getMap(String name, MapOptions options) {
        RMap map = new RedissonMap(commandExecutor, name, null, options, writeBehindService);
        return RxProxyBuilder.create(commandExecutor, map, 
                new RedissonMapRx(map, commandExecutor), RMapRx.class);
    }


    @Override
    public  RMapRx getMap(String name, Codec codec, MapOptions options) {
        RMap map = new RedissonMap(codec, commandExecutor, name, null, options, writeBehindService);
        return RxProxyBuilder.create(commandExecutor, map, 
                new RedissonMapRx(map, commandExecutor), RMapRx.class);
    }

    @Override
    public RTransactionRx createTransaction(TransactionOptions options) {
        return new RedissonTransactionRx(commandExecutor, options);
    }

    @Override
    public  RBlockingDequeRx getBlockingDeque(String name) {
        RedissonBlockingDeque deque = new RedissonBlockingDeque(commandExecutor, name, null);
        return RxProxyBuilder.create(commandExecutor, deque, 
                new RedissonBlockingDequeRx(deque), RBlockingDequeRx.class);
    }

    @Override
    public  RBlockingDequeRx getBlockingDeque(String name, Codec codec) {
        RedissonBlockingDeque deque = new RedissonBlockingDeque(codec, commandExecutor, name, null);
        return RxProxyBuilder.create(commandExecutor, deque, 
                new RedissonBlockingDequeRx(deque), RBlockingDequeRx.class);
    }

    @Override
    public  RTransferQueueRx getTransferQueue(String name) {
        String remoteName = RedissonObject.suffixName(name, "remoteService");
        RRemoteService service = getRemoteService(remoteName);
        RedissonTransferQueue queue = new RedissonTransferQueue(commandExecutor, name, service);
        return RxProxyBuilder.create(commandExecutor, queue,
                new RedissonTransferQueueRx(queue), RTransferQueueRx.class);
    }

    @Override
    public  RTransferQueueRx getTransferQueue(String name, Codec codec) {
        String remoteName = RedissonObject.suffixName(name, "remoteService");
        RRemoteService service = getRemoteService(remoteName);
        RedissonTransferQueue queue = new RedissonTransferQueue(codec, commandExecutor, name, service);
        return RxProxyBuilder.create(commandExecutor, queue,
                new RedissonTransferQueueRx(queue), RTransferQueueRx.class);
    }

    @Override
    public String getId() {
        return commandExecutor.getConnectionManager().getId();
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy