Package org.redisson.transaction
Class RedissonTransactionalMap<K,V>
- java.lang.Object
-
- org.redisson.RedissonObject
-
- org.redisson.RedissonMap<K,V>
-
- org.redisson.transaction.RedissonTransactionalMap<K,V>
-
- Type Parameters:
K
- key typeV
- value type
- All Implemented Interfaces:
ConcurrentMap<K,V>
,Map<K,V>
,RExpirable
,RExpirableAsync
,RMap<K,V>
,RMapAsync<K,V>
,RObject
,RObjectAsync
- Direct Known Subclasses:
RedissonTransactionalLocalCachedMap
public class RedissonTransactionalMap<K,V> extends RedissonMap<K,V>
- Author:
- Nikita Koksharov
-
-
Field Summary
-
Fields inherited from class org.redisson.RedissonObject
codec, commandExecutor
-
-
Constructor Summary
Constructors Constructor Description RedissonTransactionalMap(Codec codec, CommandAsyncExecutor commandExecutor, String name, List<TransactionalOperation> operations, long timeout, AtomicBoolean executed, String transactionId)
RedissonTransactionalMap(CommandAsyncExecutor commandExecutor, String name, List<TransactionalOperation> operations, long timeout, AtomicBoolean executed, String transactionId)
RedissonTransactionalMap(CommandAsyncExecutor commandExecutor, List<TransactionalOperation> operations, long timeout, AtomicBoolean executed, RMap<K,V> innerMap, String transactionId)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected RFuture<V>
addAndGetOperationAsync(K key, Number value)
protected void
checkState()
boolean
clearExpire()
Clear an expire timeout or expire date for object.RFuture<Boolean>
clearExpireAsync()
Clear an expire timeout or expire date for object in async mode.RFuture<Boolean>
containsKeyAsync(Object key)
RFuture<Boolean>
containsValueAsync(Object value)
RFuture<Boolean>
deleteAsync()
Delete object in async modeboolean
expire(long timeToLive, TimeUnit timeUnit)
Set a timeout for object.RFuture<Boolean>
expireAsync(long timeToLive, TimeUnit timeUnit)
Set a timeout for object in async mode.boolean
expireAt(long timestamp)
Set an expire date for object.boolean
expireAt(Date timestamp)
Set an expire date for object.RFuture<Boolean>
expireAtAsync(long timestamp)
Set an expire date for object in async mode.RFuture<Boolean>
expireAtAsync(Date timestamp)
Set an expire date for object in async mode.protected RFuture<Boolean>
fastPutIfAbsentOperationAsync(K key, V value)
protected RFuture<Boolean>
fastPutOperationAsync(K key, V value)
protected RFuture<Long>
fastRemoveOperationAsync(K... keys)
RFuture<Map<K,V>>
getAllOperationAsync(Set<K> keys)
RLock
getLock(K key)
ReturnsRLock
instance associated with keyRFuture<V>
getOperationAsync(K key)
RReadWriteLock
getReadWriteLock(K key)
ReturnsRReadWriteLock
instance associated with keyRFuture<Boolean>
isExistsAsync()
Check object existence in async mode.RFuture<Void>
loadAllAsync(boolean replaceExistingValues, int parallelism)
Loads all map entries to this Redis map usingMapLoader
.RFuture<Void>
loadAllAsync(Set<? extends K> keys, boolean replaceExistingValues, int parallelism)
Loads map entries usingMapLoader
whose keys are listed in definedkeys
parameter.<KOut,VOut>
RMapReduce<K,V,KOut,VOut>mapReduce()
ReturnsRMapReduce
object associated with this mapRFuture<Void>
migrateAsync(String host, int port, int database, long timeout)
Transfer object from source Redis instance to destination Redis instance in async modeRFuture<Boolean>
moveAsync(int database)
Move object to another database in async modeprotected RFuture<Void>
putAllOperationAsync(Map<? extends K,? extends V> entries)
protected RFuture<V>
putIfAbsentOperationAsync(K key, V value)
protected RFuture<V>
putOperationAsync(K key, V value)
RFuture<Set<Map.Entry<K,V>>>
readAllEntrySetAsync()
Read all map entries at onceRFuture<Set<K>>
readAllKeySetAsync()
Read all keys at onceRFuture<Map<K,V>>
readAllMapAsync()
Read all map as local instance at onceRFuture<Collection<V>>
readAllValuesAsync()
Read all values at oncelong
remainTimeToLive()
Remaining time to live of Redisson object that has a timeoutRFuture<Long>
remainTimeToLiveAsync()
Remaining time to live of Redisson object that has a timeoutprotected RFuture<Boolean>
removeOperationAsync(Object key, Object value)
protected RFuture<V>
removeOperationAsync(K key)
protected RFuture<V>
replaceOperationAsync(K key, V value)
protected RFuture<Boolean>
replaceOperationAsync(K key, V oldValue, V newValue)
MapScanResult<Object,Object>
scanIterator(String name, RedisClient client, long startPos, String pattern, int count)
RFuture<Boolean>
touchAsync()
Update the last access time of an object in async mode.RFuture<Boolean>
unlinkAsync()
Delete the objects.RFuture<Integer>
valueSizeAsync(K key)
Returns size of value mapped by key in bytes-
Methods inherited from class org.redisson.RedissonMap
addAndGet, addAndGetAsync, checkKey, checkValue, clear, containsKey, containsValue, entryIterator, entrySet, entrySet, entrySet, entrySet, equals, fastPut, fastPutAsync, fastPutIfAbsent, fastPutIfAbsentAsync, fastRemove, fastRemoveAsync, fastRemoveOperationBatchAsync, fastReplace, fastReplaceAsync, fastReplaceOperationAsync, get, getAll, getAllAsync, getAsync, getLockName, hashCode, hasNoLoader, hasNoWriter, isEmpty, keyIterator, keySet, keySet, keySet, keySet, loadAll, loadAll, mapWriterFuture, put, putAll, putAll, putAllAsync, putAllAsync, putAsync, putIfAbsent, putIfAbsentAsync, readAllEntrySet, readAllKeySet, readAllMap, readAllValues, remove, remove, removeAsync, removeAsync, replace, replace, replaceAsync, replaceAsync, scanIteratorAsync, size, sizeAsync, valueIterator, values, values, values, values, valueSize
-
Methods inherited from class org.redisson.RedissonObject
await, copy, copyAsync, delete, dump, dumpAsync, encode, encode, encode, encodeMapKey, encodeMapKeys, encodeMapValue, encodeMapValues, get, getCodec, getName, getName, isExists, migrate, move, prefixName, rename, renameAsync, renamenx, renamenxAsync, restore, restore, restoreAndReplace, restoreAndReplace, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemory, sizeInMemoryAsync, sizeInMemoryAsync, suffixName, toSeconds, touch, unlink
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.concurrent.ConcurrentMap
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAll
-
Methods inherited from interface org.redisson.api.RExpirable
clearExpire, expire, expireAt, expireAt, remainTimeToLive
-
Methods inherited from interface org.redisson.api.RExpirableAsync
remainTimeToLiveAsync
-
Methods inherited from interface org.redisson.api.RObject
copy, delete, dump, getCodec, getName, isExists, migrate, move, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, sizeInMemory, touch, unlink
-
Methods inherited from interface org.redisson.api.RObjectAsync
copyAsync, dumpAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemoryAsync
-
-
-
-
Constructor Detail
-
RedissonTransactionalMap
public RedissonTransactionalMap(CommandAsyncExecutor commandExecutor, List<TransactionalOperation> operations, long timeout, AtomicBoolean executed, RMap<K,V> innerMap, String transactionId)
-
RedissonTransactionalMap
public RedissonTransactionalMap(CommandAsyncExecutor commandExecutor, String name, List<TransactionalOperation> operations, long timeout, AtomicBoolean executed, String transactionId)
-
RedissonTransactionalMap
public RedissonTransactionalMap(Codec codec, CommandAsyncExecutor commandExecutor, String name, List<TransactionalOperation> operations, long timeout, AtomicBoolean executed, String transactionId)
-
-
Method Detail
-
expireAsync
public RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit)
Description copied from interface:RExpirableAsync
Set a timeout for object in async mode. After the timeout has expired, the key will automatically be deleted.- Specified by:
expireAsync
in interfaceRExpirableAsync
- Parameters:
timeToLive
- - timeout before object will be deletedtimeUnit
- - timeout time unit- Returns:
true
if the timeout was set andfalse
if not
-
expireAtAsync
public RFuture<Boolean> expireAtAsync(Date timestamp)
Description copied from interface:RExpirableAsync
Set an expire date for object in async mode. When expire date comes the key will automatically be deleted.- Specified by:
expireAtAsync
in interfaceRExpirableAsync
- Parameters:
timestamp
- - expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireAtAsync
public RFuture<Boolean> expireAtAsync(long timestamp)
Description copied from interface:RExpirableAsync
Set an expire date for object in async mode. When expire date comes the key will automatically be deleted.- Specified by:
expireAtAsync
in interfaceRExpirableAsync
- Parameters:
timestamp
- - expire date in milliseconds (Unix timestamp)- Returns:
true
if the timeout was set andfalse
if not
-
clearExpireAsync
public RFuture<Boolean> clearExpireAsync()
Description copied from interface:RExpirableAsync
Clear an expire timeout or expire date for object in async mode. Object will not be deleted.- Specified by:
clearExpireAsync
in interfaceRExpirableAsync
- Returns:
true
if the timeout was cleared andfalse
if not
-
moveAsync
public RFuture<Boolean> moveAsync(int database)
Description copied from interface:RObjectAsync
Move object to another database in async mode- Specified by:
moveAsync
in interfaceRObjectAsync
- Overrides:
moveAsync
in classRedissonObject
- Parameters:
database
- - number of Redis database- Returns:
true
if key was movedfalse
if not
-
migrateAsync
public RFuture<Void> migrateAsync(String host, int port, int database, long timeout)
Description copied from interface:RObjectAsync
Transfer object from source Redis instance to destination Redis instance in async mode- Specified by:
migrateAsync
in interfaceRObjectAsync
- Overrides:
migrateAsync
in classRedissonObject
- Parameters:
host
- - destination hostport
- - destination portdatabase
- - destination databasetimeout
- - maximum idle time in any moment of the communication with the destination instance in milliseconds- Returns:
- void
-
mapReduce
public <KOut,VOut> RMapReduce<K,V,KOut,VOut> mapReduce()
Description copied from interface:RMap
ReturnsRMapReduce
object associated with this map
-
scanIterator
public MapScanResult<Object,Object> scanIterator(String name, RedisClient client, long startPos, String pattern, int count)
- Overrides:
scanIterator
in classRedissonMap<K,V>
-
containsKeyAsync
public RFuture<Boolean> containsKeyAsync(Object key)
- Specified by:
containsKeyAsync
in interfaceRMapAsync<K,V>
- Overrides:
containsKeyAsync
in classRedissonMap<K,V>
-
containsValueAsync
public RFuture<Boolean> containsValueAsync(Object value)
- Specified by:
containsValueAsync
in interfaceRMapAsync<K,V>
- Overrides:
containsValueAsync
in classRedissonMap<K,V>
-
addAndGetOperationAsync
protected RFuture<V> addAndGetOperationAsync(K key, Number value)
- Overrides:
addAndGetOperationAsync
in classRedissonMap<K,V>
-
putIfAbsentOperationAsync
protected RFuture<V> putIfAbsentOperationAsync(K key, V value)
- Overrides:
putIfAbsentOperationAsync
in classRedissonMap<K,V>
-
putOperationAsync
protected RFuture<V> putOperationAsync(K key, V value)
- Overrides:
putOperationAsync
in classRedissonMap<K,V>
-
fastPutIfAbsentOperationAsync
protected RFuture<Boolean> fastPutIfAbsentOperationAsync(K key, V value)
- Overrides:
fastPutIfAbsentOperationAsync
in classRedissonMap<K,V>
-
fastPutOperationAsync
protected RFuture<Boolean> fastPutOperationAsync(K key, V value)
- Overrides:
fastPutOperationAsync
in classRedissonMap<K,V>
-
fastRemoveOperationAsync
protected RFuture<Long> fastRemoveOperationAsync(K... keys)
- Overrides:
fastRemoveOperationAsync
in classRedissonMap<K,V>
-
valueSizeAsync
public RFuture<Integer> valueSizeAsync(K key)
Description copied from interface:RMapAsync
Returns size of value mapped by key in bytes- Specified by:
valueSizeAsync
in interfaceRMapAsync<K,V>
- Overrides:
valueSizeAsync
in classRedissonMap<K,V>
- Parameters:
key
- - map key- Returns:
- size of value
-
getOperationAsync
public RFuture<V> getOperationAsync(K key)
- Overrides:
getOperationAsync
in classRedissonMap<K,V>
-
readAllKeySetAsync
public RFuture<Set<K>> readAllKeySetAsync()
Description copied from interface:RMapAsync
Read all keys at once- Specified by:
readAllKeySetAsync
in interfaceRMapAsync<K,V>
- Overrides:
readAllKeySetAsync
in classRedissonMap<K,V>
- Returns:
- keys
-
readAllEntrySetAsync
public RFuture<Set<Map.Entry<K,V>>> readAllEntrySetAsync()
Description copied from interface:RMapAsync
Read all map entries at once- Specified by:
readAllEntrySetAsync
in interfaceRMapAsync<K,V>
- Overrides:
readAllEntrySetAsync
in classRedissonMap<K,V>
- Returns:
- entries
-
readAllValuesAsync
public RFuture<Collection<V>> readAllValuesAsync()
Description copied from interface:RMapAsync
Read all values at once- Specified by:
readAllValuesAsync
in interfaceRMapAsync<K,V>
- Overrides:
readAllValuesAsync
in classRedissonMap<K,V>
- Returns:
- values
-
readAllMapAsync
public RFuture<Map<K,V>> readAllMapAsync()
Description copied from interface:RMapAsync
Read all map as local instance at once- Specified by:
readAllMapAsync
in interfaceRMapAsync<K,V>
- Overrides:
readAllMapAsync
in classRedissonMap<K,V>
- Returns:
- map
-
getAllOperationAsync
public RFuture<Map<K,V>> getAllOperationAsync(Set<K> keys)
- Overrides:
getAllOperationAsync
in classRedissonMap<K,V>
-
removeOperationAsync
protected RFuture<V> removeOperationAsync(K key)
- Overrides:
removeOperationAsync
in classRedissonMap<K,V>
-
removeOperationAsync
protected RFuture<Boolean> removeOperationAsync(Object key, Object value)
- Overrides:
removeOperationAsync
in classRedissonMap<K,V>
-
putAllOperationAsync
protected RFuture<Void> putAllOperationAsync(Map<? extends K,? extends V> entries)
- Overrides:
putAllOperationAsync
in classRedissonMap<K,V>
-
replaceOperationAsync
protected RFuture<Boolean> replaceOperationAsync(K key, V oldValue, V newValue)
- Overrides:
replaceOperationAsync
in classRedissonMap<K,V>
-
touchAsync
public RFuture<Boolean> touchAsync()
Description copied from interface:RObjectAsync
Update the last access time of an object in async mode.- Specified by:
touchAsync
in interfaceRObjectAsync
- Overrides:
touchAsync
in classRedissonObject
- Returns:
true
if object was touched elsefalse
-
isExistsAsync
public RFuture<Boolean> isExistsAsync()
Description copied from interface:RObjectAsync
Check object existence in async mode.- Specified by:
isExistsAsync
in interfaceRObjectAsync
- Overrides:
isExistsAsync
in classRedissonObject
- Returns:
true
if object exists andfalse
otherwise
-
unlinkAsync
public RFuture<Boolean> unlinkAsync()
Description copied from interface:RObjectAsync
Delete the objects. Actual removal will happen later asynchronously.Requires Redis 4.0+
- Specified by:
unlinkAsync
in interfaceRObjectAsync
- Overrides:
unlinkAsync
in classRedissonObject
- Returns:
true
if it was exist and deleted elsefalse
-
deleteAsync
public RFuture<Boolean> deleteAsync()
Description copied from interface:RObjectAsync
Delete object in async mode- Specified by:
deleteAsync
in interfaceRObjectAsync
- Overrides:
deleteAsync
in classRedissonObject
- Returns:
true
if object was deletedfalse
if not
-
replaceOperationAsync
protected RFuture<V> replaceOperationAsync(K key, V value)
- Overrides:
replaceOperationAsync
in classRedissonMap<K,V>
-
checkState
protected void checkState()
-
loadAllAsync
public RFuture<Void> loadAllAsync(boolean replaceExistingValues, int parallelism)
Description copied from interface:RMapAsync
Loads all map entries to this Redis map usingMapLoader
.- Specified by:
loadAllAsync
in interfaceRMapAsync<K,V>
- Overrides:
loadAllAsync
in classRedissonMap<K,V>
- Parameters:
replaceExistingValues
- -true
if existed values should be replaced,false
otherwise.parallelism
- - parallelism level, used to increase speed of process execution- Returns:
- void
-
loadAllAsync
public RFuture<Void> loadAllAsync(Set<? extends K> keys, boolean replaceExistingValues, int parallelism)
Description copied from interface:RMapAsync
Loads map entries usingMapLoader
whose keys are listed in definedkeys
parameter.- Specified by:
loadAllAsync
in interfaceRMapAsync<K,V>
- Overrides:
loadAllAsync
in classRedissonMap<K,V>
- Parameters:
keys
- - map keysreplaceExistingValues
- -true
if existed values should be replaced,false
otherwise.parallelism
- - parallelism level, used to increase speed of process execution- Returns:
- void
-
getLock
public RLock getLock(K key)
Description copied from interface:RMap
ReturnsRLock
instance associated with key
-
getReadWriteLock
public RReadWriteLock getReadWriteLock(K key)
Description copied from interface:RMap
ReturnsRReadWriteLock
instance associated with key- Specified by:
getReadWriteLock
in interfaceRMap<K,V>
- Overrides:
getReadWriteLock
in classRedissonMap<K,V>
- Parameters:
key
- - map key- Returns:
- readWriteLock
-
expire
public boolean expire(long timeToLive, TimeUnit timeUnit)
Description copied from interface:RExpirable
Set a timeout for object. After the timeout has expired, the key will automatically be deleted.- Specified by:
expire
in interfaceRExpirable
- Parameters:
timeToLive
- - timeout before object will be deletedtimeUnit
- - timeout time unit- Returns:
true
if the timeout was set andfalse
if not
-
expireAt
public boolean expireAt(long timestamp)
Description copied from interface:RExpirable
Set an expire date for object. When expire date comes the key will automatically be deleted.- Specified by:
expireAt
in interfaceRExpirable
- Parameters:
timestamp
- - expire date in milliseconds (Unix timestamp)- Returns:
true
if the timeout was set andfalse
if not
-
expireAt
public boolean expireAt(Date timestamp)
Description copied from interface:RExpirable
Set an expire date for object. When expire date comes the key will automatically be deleted.- Specified by:
expireAt
in interfaceRExpirable
- Parameters:
timestamp
- - expire date- Returns:
true
if the timeout was set andfalse
if not
-
clearExpire
public boolean clearExpire()
Description copied from interface:RExpirable
Clear an expire timeout or expire date for object.- Specified by:
clearExpire
in interfaceRExpirable
- Returns:
true
if timeout was removedfalse
if object does not exist or does not have an associated timeout
-
remainTimeToLive
public long remainTimeToLive()
Description copied from interface:RExpirable
Remaining time to live of Redisson object that has a timeout- Specified by:
remainTimeToLive
in interfaceRExpirable
- Returns:
- time in milliseconds -2 if the key does not exist. -1 if the key exists but has no associated expire.
-
remainTimeToLiveAsync
public RFuture<Long> remainTimeToLiveAsync()
Description copied from interface:RExpirableAsync
Remaining time to live of Redisson object that has a timeout- Specified by:
remainTimeToLiveAsync
in interfaceRExpirableAsync
- Returns:
- time in milliseconds -2 if the key does not exist. -1 if the key exists but has no associated expire.
-
-