Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.redisson.reactive.RedissonBatchReactive Maven / Gradle / Ivy
/**
* Copyright 2018 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 java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
import org.reactivestreams.Publisher;
import org.redisson.api.BatchOptions;
import org.redisson.api.BatchResult;
import org.redisson.api.RAtomicLongReactive;
import org.redisson.api.RBatchReactive;
import org.redisson.api.RBitSetReactive;
import org.redisson.api.RBlockingQueueReactive;
import org.redisson.api.RBucketReactive;
import org.redisson.api.RDequeReactive;
import org.redisson.api.RFuture;
import org.redisson.api.RHyperLogLogReactive;
import org.redisson.api.RKeysReactive;
import org.redisson.api.RLexSortedSetReactive;
import org.redisson.api.RListReactive;
import org.redisson.api.RMapCacheReactive;
import org.redisson.api.RMapReactive;
import org.redisson.api.RQueueReactive;
import org.redisson.api.RScoredSortedSetReactive;
import org.redisson.api.RScriptReactive;
import org.redisson.api.RSetCacheReactive;
import org.redisson.api.RSetReactive;
import org.redisson.api.RTopicReactive;
import org.redisson.api.RedissonReactiveClient;
import org.redisson.client.codec.Codec;
import org.redisson.command.CommandReactiveBatchService;
import org.redisson.command.CommandReactiveService;
import org.redisson.connection.ConnectionManager;
import org.redisson.eviction.EvictionScheduler;
/**
*
* @author Nikita Koksharov
*
*/
public class RedissonBatchReactive implements RBatchReactive {
private final EvictionScheduler evictionScheduler;
private final CommandReactiveBatchService executorService;
private final BatchOptions options;
private final CommandReactiveService commandExecutor;
public RedissonBatchReactive(EvictionScheduler evictionScheduler, ConnectionManager connectionManager, CommandReactiveService commandExecutor, BatchOptions options) {
this.evictionScheduler = evictionScheduler;
this.executorService = new CommandReactiveBatchService(connectionManager);
this.commandExecutor = commandExecutor;
this.options = options;
}
@Override
public RBucketReactive getBucket(String name) {
return new RedissonBucketReactive(executorService, name);
}
@Override
public RBucketReactive getBucket(String name, Codec codec) {
return new RedissonBucketReactive(codec, executorService, name);
}
@Override
public RHyperLogLogReactive getHyperLogLog(String name) {
return new RedissonHyperLogLogReactive(executorService, name);
}
@Override
public RHyperLogLogReactive getHyperLogLog(String name, Codec codec) {
return new RedissonHyperLogLogReactive(codec, executorService, name);
}
@Override
public RListReactive getList(String name) {
return new RedissonListReactive(executorService, name);
}
@Override
public RListReactive getList(String name, Codec codec) {
return new RedissonListReactive(codec, executorService, name);
}
@Override
public RMapReactive getMap(String name) {
return new RedissonMapReactive(executorService, name, null);
}
@Override
public RMapReactive getMap(String name, Codec codec) {
return new RedissonMapReactive(codec, executorService, name, null);
}
@Override
public RMapCacheReactive getMapCache(String name, Codec codec) {
return new RedissonMapCacheReactive(evictionScheduler, codec, executorService, name, null);
}
@Override
public RMapCacheReactive getMapCache(String name) {
return new RedissonMapCacheReactive(evictionScheduler, executorService, name, null);
}
@Override
public RSetReactive getSet(String name) {
return new RedissonSetReactive(executorService, name);
}
@Override
public RSetReactive getSet(String name, Codec codec) {
return new RedissonSetReactive(codec, executorService, name);
}
@Override
public RTopicReactive getTopic(String name) {
return new RedissonTopicReactive(executorService, name);
}
@Override
public RTopicReactive getTopic(String name, Codec codec) {
return new RedissonTopicReactive(codec, executorService, name);
}
@Override
public RQueueReactive getQueue(String name) {
return new RedissonQueueReactive(executorService, name);
}
@Override
public RQueueReactive getQueue(String name, Codec codec) {
return new RedissonQueueReactive(codec, executorService, name);
}
@Override
public RBlockingQueueReactive getBlockingQueue(String name) {
return new RedissonBlockingQueueReactive(executorService, name);
}
@Override
public RBlockingQueueReactive getBlockingQueue(String name, Codec codec) {
return new RedissonBlockingQueueReactive(codec, executorService, name);
}
@Override
public RDequeReactive getDequeReactive(String name) {
return new RedissonDequeReactive(executorService, name);
}
@Override
public RDequeReactive getDequeReactive(String name, Codec codec) {
return new RedissonDequeReactive(codec, executorService, name);
}
@Override
public RAtomicLongReactive getAtomicLongReactive(String name) {
return new RedissonAtomicLongReactive(executorService, name);
}
@Override
public RSetCacheReactive getSetCache(String name) {
return new RedissonSetCacheReactive(evictionScheduler, executorService, name);
}
@Override
public RSetCacheReactive getSetCache(String name, Codec codec) {
return new RedissonSetCacheReactive(codec, evictionScheduler, executorService, name);
}
@Override
public RScoredSortedSetReactive getScoredSortedSet(String name) {
return new RedissonScoredSortedSetReactive(executorService, name);
}
@Override
public RScoredSortedSetReactive getScoredSortedSet(String name, Codec codec) {
return new RedissonScoredSortedSetReactive(codec, executorService, name);
}
@Override
public RLexSortedSetReactive getLexSortedSet(String name) {
return new RedissonLexSortedSetReactive(executorService, name);
}
@Override
public RBitSetReactive getBitSet(String name) {
return new RedissonBitSetReactive(executorService, name);
}
@Override
public RScriptReactive getScript() {
return new RedissonScriptReactive(executorService);
}
@Override
public RKeysReactive getKeys() {
return new RedissonKeysReactive(executorService);
}
@Override
public Publisher> execute() {
return commandExecutor.reactive(new Supplier>>() {
@Override
public RFuture> get() {
return executorService.executeAsync(options);
}
});
}
public RBatchReactive atomic() {
options.atomic();
return this;
}
@Override
public RBatchReactive syncSlaves(int slaves, long timeout, TimeUnit unit) {
options.syncSlaves(slaves, timeout, unit);
return this;
}
@Override
public RBatchReactive skipResult() {
options.skipResult();
return this;
}
@Override
public RBatchReactive retryAttempts(int retryAttempts) {
options.retryAttempts(retryAttempts);
return this;
}
@Override
public RBatchReactive retryInterval(long retryInterval, TimeUnit unit) {
options.retryInterval(retryInterval, unit);
return this;
}
@Override
public RBatchReactive timeout(long timeout, TimeUnit unit) {
options.responseTimeout(timeout, unit);
return this;
}
public void enableRedissonReferenceSupport(RedissonReactiveClient redissonReactive) {
this.executorService.enableRedissonReferenceSupport(redissonReactive);
}
}