Package org.redisson.transaction
Class RedissonTransactionalBucket<V>
- java.lang.Object
-
- org.redisson.RedissonObject
-
- org.redisson.RedissonBucket<V>
-
- org.redisson.transaction.RedissonTransactionalBucket<V>
-
- Type Parameters:
V
- value type
- All Implemented Interfaces:
RBucket<V>
,RBucketAsync<V>
,RExpirable
,RExpirableAsync
,RObject
,RObjectAsync
public class RedissonTransactionalBucket<V> extends RedissonBucket<V>
- Author:
- Nikita Koksharov
-
-
Field Summary
-
Fields inherited from class org.redisson.RedissonObject
codec, commandExecutor, name
-
-
Constructor Summary
Constructors Constructor Description RedissonTransactionalBucket(Codec codec, CommandAsyncExecutor commandExecutor, long timeout, String name, List<TransactionalOperation> operations, AtomicBoolean executed, String transactionId)
RedissonTransactionalBucket(CommandAsyncExecutor commandExecutor, long timeout, String name, List<TransactionalOperation> operations, AtomicBoolean executed, String transactionId)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.protected RFuture<Boolean>
clearExpireAsync(String... keys)
RFuture<Boolean>
compareAndSetAsync(V expect, V update)
Atomically sets the value to the given updated value only if serialized state of the current value equals to serialized state of the expected value.RFuture<Boolean>
deleteAsync()
Delete object in async modeprotected <R> void
executeLocked(RPromise<R> promise, Runnable runnable)
boolean
expire(long timeToLive, TimeUnit timeUnit)
Set a timeout for object.boolean
expire(Instant instant)
Set an expire date for object.RFuture<Boolean>
expireAsync(long timeToLive, TimeUnit timeUnit)
Set a timeout for object in async mode.protected RFuture<Boolean>
expireAsync(long timeToLive, TimeUnit timeUnit, String... keys)
RFuture<Boolean>
expireAsync(Instant timestamp)
Set an expire date for object.boolean
expireAt(long timestamp)
UseRExpirable.expire(Instant)
insteadboolean
expireAt(Date timestamp)
UseRExpirable.expire(Instant)
insteadRFuture<Boolean>
expireAtAsync(long timestamp)
UseRExpirableAsync.expireAsync(Instant)
insteadprotected RFuture<Boolean>
expireAtAsync(long timestamp, String... keys)
RFuture<Boolean>
expireAtAsync(Date timestamp)
UseRExpirableAsync.expireAsync(Instant)
insteadRFuture<V>
getAndDeleteAsync()
Retrieves element in the holder and removes it.RFuture<V>
getAndSetAsync(V value)
Retrieves current element in the holder and replaces it withnewValue
.RFuture<V>
getAndSetAsync(V value, long timeToLive, TimeUnit timeUnit)
Retrieves current element in the holder and replaces it withnewValue
with definedtimeToLive
interval.RFuture<V>
getAsync()
Retrieves element stored in the holder.RFuture<Boolean>
isExistsAsync()
Check object existence in async mode.RFuture<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 modelong
remainTimeToLive()
Remaining time to live of Redisson object that has a timeoutRFuture<Long>
remainTimeToLiveAsync()
Remaining time to live of Redisson object that has a timeoutRFuture<Void>
setAsync(V newValue)
Stores element into the holder.RFuture<Void>
setAsync(V value, long timeToLive, TimeUnit timeUnit)
Stores element into the holder with definedtimeToLive
interval.RFuture<Long>
sizeAsync()
Returns size of object in bytesRFuture<Boolean>
touchAsync()
Update the last access time of an object in async mode.RFuture<Boolean>
trySetAsync(V newValue)
Tries to set element atomically into empty holder.RFuture<Boolean>
trySetAsync(V value, long timeToLive, TimeUnit timeUnit)
Tries to set element atomically into empty holder with definedtimeToLive
interval.RFuture<Boolean>
unlinkAsync()
Delete the objects.-
Methods inherited from class org.redisson.RedissonBucket
addListener, addListenerAsync, compareAndSet, get, getAndDelete, getAndSet, getAndSet, removeListener, removeListenerAsync, set, set, setAndKeepTTL, setAndKeepTTLAsync, setIfExists, setIfExists, setIfExistsAsync, setIfExistsAsync, size, trySet, trySet
-
Methods inherited from class org.redisson.RedissonObject
addListener, addListenerAsync, copy, copyAsync, delete, deleteAsync, dump, dumpAsync, encode, encode, encode, encode, encodeMapKey, encodeMapKeys, encodeMapValue, encodeMapValues, get, getCodec, getIdleTime, getIdleTimeAsync, getLockByMapKey, getLockByValue, getName, getRawName, getRawName, isExists, migrate, move, prefixName, removeListenersAsync, rename, renameAsync, renamenx, renamenxAsync, restore, restore, restoreAndReplace, restoreAndReplace, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, setName, sizeInMemory, sizeInMemoryAsync, sizeInMemoryAsync, sizeInMemoryAsync, suffixName, toSeconds, toStream, touch, unlink
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.redisson.api.RExpirable
clearExpire, expire, 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, getIdleTime, getName, isExists, migrate, move, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, sizeInMemory, touch, unlink
-
Methods inherited from interface org.redisson.api.RObjectAsync
copyAsync, dumpAsync, getIdleTimeAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemoryAsync
-
-
-
-
Constructor Detail
-
RedissonTransactionalBucket
public RedissonTransactionalBucket(CommandAsyncExecutor commandExecutor, long timeout, String name, List<TransactionalOperation> operations, AtomicBoolean executed, String transactionId)
-
RedissonTransactionalBucket
public RedissonTransactionalBucket(Codec codec, CommandAsyncExecutor commandExecutor, long timeout, String name, List<TransactionalOperation> operations, 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
UseRExpirableAsync.expireAsync(Instant)
instead- 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
UseRExpirableAsync.expireAsync(Instant)
instead- Specified by:
expireAtAsync
in interfaceRExpirableAsync
- Parameters:
timestamp
- - expire date in milliseconds (Unix timestamp)- Returns:
true
if the timeout was set andfalse
if not
-
expireAsync
public RFuture<Boolean> expireAsync(Instant timestamp)
Description copied from interface:RExpirableAsync
Set an expire date for object. When expire date comes the key will automatically be deleted.- Specified by:
expireAsync
in interfaceRExpirableAsync
- Parameters:
timestamp
- - expire date- 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
-
sizeAsync
public RFuture<Long> sizeAsync()
Description copied from interface:RBucketAsync
Returns size of object in bytes- Specified by:
sizeAsync
in interfaceRBucketAsync<V>
- Overrides:
sizeAsync
in classRedissonBucket<V>
- Returns:
- object size
-
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
-
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
-
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
-
getAsync
public RFuture<V> getAsync()
Description copied from interface:RBucketAsync
Retrieves element stored in the holder.- Specified by:
getAsync
in interfaceRBucketAsync<V>
- Overrides:
getAsync
in classRedissonBucket<V>
- Returns:
- element
-
compareAndSetAsync
public RFuture<Boolean> compareAndSetAsync(V expect, V update)
Description copied from interface:RBucketAsync
Atomically sets the value to the given updated value only if serialized state of the current value equals to serialized state of the expected value.- Specified by:
compareAndSetAsync
in interfaceRBucketAsync<V>
- Overrides:
compareAndSetAsync
in classRedissonBucket<V>
- Parameters:
expect
- the expected valueupdate
- the new value- Returns:
true
if successful; orfalse
if the actual value was not equal to the expected value.
-
getAndSetAsync
public RFuture<V> getAndSetAsync(V value, long timeToLive, TimeUnit timeUnit)
Description copied from interface:RBucketAsync
Retrieves current element in the holder and replaces it withnewValue
with definedtimeToLive
interval.- Specified by:
getAndSetAsync
in interfaceRBucketAsync<V>
- Overrides:
getAndSetAsync
in classRedissonBucket<V>
- Parameters:
value
- - value to settimeToLive
- - time to live intervaltimeUnit
- - unit of time to live interval- Returns:
- previous value
-
getAndSetAsync
public RFuture<V> getAndSetAsync(V value)
Description copied from interface:RBucketAsync
Retrieves current element in the holder and replaces it withnewValue
.- Specified by:
getAndSetAsync
in interfaceRBucketAsync<V>
- Overrides:
getAndSetAsync
in classRedissonBucket<V>
- Parameters:
value
- - value to set- Returns:
- previous value
-
getAndDeleteAsync
public RFuture<V> getAndDeleteAsync()
Description copied from interface:RBucketAsync
Retrieves element in the holder and removes it.- Specified by:
getAndDeleteAsync
in interfaceRBucketAsync<V>
- Overrides:
getAndDeleteAsync
in classRedissonBucket<V>
- Returns:
- element
-
setAsync
public RFuture<Void> setAsync(V newValue)
Description copied from interface:RBucketAsync
Stores element into the holder.- Specified by:
setAsync
in interfaceRBucketAsync<V>
- Overrides:
setAsync
in classRedissonBucket<V>
- Parameters:
newValue
- - value to set- Returns:
- void
-
setAsync
public RFuture<Void> setAsync(V value, long timeToLive, TimeUnit timeUnit)
Description copied from interface:RBucketAsync
Stores element into the holder with definedtimeToLive
interval.- Specified by:
setAsync
in interfaceRBucketAsync<V>
- Overrides:
setAsync
in classRedissonBucket<V>
- Parameters:
value
- - value to settimeToLive
- - time to live intervaltimeUnit
- - unit of time to live interval- Returns:
- void
-
trySetAsync
public RFuture<Boolean> trySetAsync(V newValue)
Description copied from interface:RBucketAsync
Tries to set element atomically into empty holder.- Specified by:
trySetAsync
in interfaceRBucketAsync<V>
- Overrides:
trySetAsync
in classRedissonBucket<V>
- Parameters:
newValue
- - value to set- Returns:
true
if successful, orfalse
if element was already set
-
trySetAsync
public RFuture<Boolean> trySetAsync(V value, long timeToLive, TimeUnit timeUnit)
Description copied from interface:RBucketAsync
Tries to set element atomically into empty holder with definedtimeToLive
interval.- Specified by:
trySetAsync
in interfaceRBucketAsync<V>
- Overrides:
trySetAsync
in classRedissonBucket<V>
- Parameters:
value
- - value to settimeToLive
- - time to live intervaltimeUnit
- - unit of time to live interval- Returns:
true
if successful, orfalse
if element was already set
-
checkState
protected void checkState()
-
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
UseRExpirable.expire(Instant)
instead- Specified by:
expireAt
in interfaceRExpirable
- Parameters:
timestamp
- - expire date in milliseconds (Unix timestamp)- Returns:
true
if the timeout was set andfalse
if not
-
expire
public boolean expire(Instant instant)
Description copied from interface:RExpirable
Set an expire date for object. When expire date comes the key will automatically be deleted.- Specified by:
expire
in interfaceRExpirable
- Parameters:
instant
- - expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireAt
public boolean expireAt(Date timestamp)
Description copied from interface:RExpirable
UseRExpirable.expire(Instant)
instead- 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.
-
expireAsync
protected RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit, String... keys)
-
-