com.github.lontime.shaded.org.redisson.transaction.RedissonTransactionalMapCache 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.transaction;
import com.github.lontime.shaded.org.redisson.RedissonMapCache;
import com.github.lontime.shaded.org.redisson.ScanResult;
import com.github.lontime.shaded.org.redisson.api.*;
import com.github.lontime.shaded.org.redisson.api.mapreduce.RMapReduce;
import com.github.lontime.shaded.org.redisson.client.RedisClient;
import com.github.lontime.shaded.org.redisson.client.codec.Codec;
import com.github.lontime.shaded.org.redisson.command.CommandAsyncExecutor;
import com.github.lontime.shaded.org.redisson.transaction.operation.TransactionalOperation;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
/**
*
* @author Nikita Koksharov
*
* @param key type
* @param value type
*/
public class RedissonTransactionalMapCache extends RedissonMapCache {
private final BaseTransactionalMapCache transactionalMap;
private final AtomicBoolean executed;
public RedissonTransactionalMapCache(CommandAsyncExecutor commandExecutor, String name,
List operations, long timeout, AtomicBoolean executed, String transactionId) {
super(null, commandExecutor, name, null, null, null);
this.executed = executed;
RedissonMapCache innerMap = new RedissonMapCache(null, commandExecutor, name, null, null, null);
this.transactionalMap = new BaseTransactionalMapCache(commandExecutor, timeout, operations, innerMap, transactionId);
}
public RedissonTransactionalMapCache(Codec codec, CommandAsyncExecutor commandExecutor, String name,
List operations, long timeout, AtomicBoolean executed, String transactionId) {
super(codec, null, commandExecutor, name, null, null, null);
this.executed = executed;
RedissonMapCache innerMap = new RedissonMapCache(codec, null, commandExecutor, name, null, null, null);
this.transactionalMap = new BaseTransactionalMapCache(commandExecutor, timeout, operations, innerMap, transactionId);
}
@Override
public RFuture expireAsync(long timeToLive, TimeUnit timeUnit, String param, String... keys) {
return transactionalMap.expireAsync(timeToLive, timeUnit, param, keys);
}
@Override
protected RFuture expireAtAsync(long timestamp, String param, String... keys) {
return transactionalMap.expireAtAsync(timestamp, param, keys);
}
@Override
public RFuture clearExpireAsync() {
return transactionalMap.clearExpireAsync();
}
@Override
public RFuture moveAsync(int database) {
throw new UnsupportedOperationException("moveAsync method is not supported in transaction");
}
@Override
public RFuture migrateAsync(String host, int port, int database, long timeout) {
throw new UnsupportedOperationException("migrateAsync method is not supported in transaction");
}
@Override
public RFuture touchAsync() {
checkState();
return transactionalMap.touchAsync(commandExecutor);
}
@Override
public RFuture isExistsAsync() {
checkState();
return transactionalMap.isExistsAsync();
}
@Override
public RFuture unlinkAsync() {
return transactionalMap.unlinkAsync(commandExecutor);
}
@Override
public RFuture deleteAsync() {
checkState();
return transactionalMap.deleteAsync(commandExecutor);
}
@Override
public RFuture putIfAbsentAsync(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit) {
return transactionalMap.putIfAbsentAsync(key, value, ttl, ttlUnit, maxIdleTime, maxIdleUnit);
}
@Override
public RFuture fastPutOperationAsync(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit) {
return transactionalMap.fastPutOperationAsync(key, value, ttl, ttlUnit, maxIdleTime, maxIdleUnit);
}
@Override
public RFuture putOperationAsync(K key, V value, long ttlTimeout, long maxIdleTimeout, long maxIdleDelta, long ttlTimeoutDelta) {
return transactionalMap.putOperationAsync(key, value, ttlTimeout, maxIdleTimeout, maxIdleDelta, ttlTimeoutDelta);
}
public RFuture fastPutIfAbsentAsync(final K key, final V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit) {
return transactionalMap.fastPutIfAbsentAsync(key, value, ttl, ttlUnit, maxIdleTime, maxIdleUnit);
}
@Override
public RFuture remainTimeToLiveAsync() {
throw new UnsupportedOperationException("remainTimeToLiveAsync method is not supported in transaction");
}
@Override
public RFuture setMaxSizeAsync(int maxSize) {
throw new UnsupportedOperationException("setMaxSize method is not supported in transaction");
}
@Override
public RFuture trySetMaxSizeAsync(int maxSize) {
throw new UnsupportedOperationException("trySetMaxSize method is not supported in transaction");
}
@Override
public RMapReduce mapReduce() {
throw new UnsupportedOperationException("mapReduce method is not supported in transaction");
}
@Override
public ScanResult> scanIterator(String name, RedisClient client,
long startPos, String pattern, int count) {
checkState();
return transactionalMap.scanIterator(name, client, startPos, pattern, count);
}
@Override
public RFuture containsKeyAsync(Object key) {
checkState();
return transactionalMap.containsKeyAsync(key);
}
@Override
public RFuture containsValueAsync(Object value) {
checkState();
return transactionalMap.containsValueAsync(value);
}
@Override
protected RFuture addAndGetOperationAsync(K key, Number value) {
checkState();
return transactionalMap.addAndGetOperationAsync(key, value);
}
@Override
protected RFuture fastPutIfExistsOperationAsync(K key, V value) {
checkState();
return transactionalMap.fastPutIfExistsOperationAsync(key, value);
}
@Override
protected RFuture putIfExistsOperationAsync(K key, V value) {
checkState();
return transactionalMap.putIfExistsOperationAsync(key, value);
}
@Override
protected RFuture putIfAbsentOperationAsync(K key, V value) {
checkState();
return transactionalMap.putIfAbsentOperationAsync(key, value);
}
@Override
protected RFuture putOperationAsync(K key, V value) {
checkState();
return transactionalMap.putOperationAsync(key, value);
}
@Override
protected RFuture fastPutIfAbsentOperationAsync(K key, V value) {
checkState();
return transactionalMap.fastPutIfAbsentOperationAsync(key, value);
}
@Override
protected RFuture fastPutOperationAsync(K key, V value) {
checkState();
return transactionalMap.fastPutOperationAsync(key, value);
}
@Override
@SuppressWarnings("unchecked")
protected RFuture fastRemoveOperationAsync(K... keys) {
checkState();
return transactionalMap.fastRemoveOperationAsync(keys);
}
@Override
public RFuture valueSizeAsync(K key) {
checkState();
return transactionalMap.valueSizeAsync(key);
}
@Override
public RFuture getOperationAsync(K key) {
checkState();
return transactionalMap.getOperationAsync(key);
}
@Override
public RFuture> readAllKeySetAsync() {
checkState();
return transactionalMap.readAllKeySetAsync();
}
@Override
public RFuture>> readAllEntrySetAsync() {
checkState();
return transactionalMap.readAllEntrySetAsync();
}
@Override
public RFuture> readAllValuesAsync() {
checkState();
return transactionalMap.readAllValuesAsync();
}
@Override
public RFuture