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 voidcheckState()booleanclearExpire()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> voidexecuteLocked(RPromise<R> promise, Runnable runnable)booleanexpire(long timeToLive, TimeUnit timeUnit)Set a timeout for object.booleanexpire(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.booleanexpireAt(long timestamp)UseRExpirable.expire(Instant)insteadbooleanexpireAt(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 withnewValuewith definedtimeToLiveinterval.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 modelongremainTimeToLive()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 definedtimeToLiveinterval.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 definedtimeToLiveinterval.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:RExpirableAsyncSet a timeout for object in async mode. After the timeout has expired, the key will automatically be deleted.- Specified by:
expireAsyncin interfaceRExpirableAsync- Parameters:
timeToLive- - timeout before object will be deletedtimeUnit- - timeout time unit- Returns:
trueif the timeout was set andfalseif not
-
expireAtAsync
public RFuture<Boolean> expireAtAsync(Date timestamp)
Description copied from interface:RExpirableAsyncUseRExpirableAsync.expireAsync(Instant)instead- Specified by:
expireAtAsyncin interfaceRExpirableAsync- Parameters:
timestamp- - expire date- Returns:
trueif the timeout was set andfalseif not
-
expireAtAsync
public RFuture<Boolean> expireAtAsync(long timestamp)
Description copied from interface:RExpirableAsyncUseRExpirableAsync.expireAsync(Instant)instead- Specified by:
expireAtAsyncin interfaceRExpirableAsync- Parameters:
timestamp- - expire date in milliseconds (Unix timestamp)- Returns:
trueif the timeout was set andfalseif not
-
expireAsync
public RFuture<Boolean> expireAsync(Instant timestamp)
Description copied from interface:RExpirableAsyncSet an expire date for object. When expire date comes the key will automatically be deleted.- Specified by:
expireAsyncin interfaceRExpirableAsync- Parameters:
timestamp- - expire date- Returns:
trueif the timeout was set andfalseif not
-
clearExpireAsync
public RFuture<Boolean> clearExpireAsync()
Description copied from interface:RExpirableAsyncClear an expire timeout or expire date for object in async mode. Object will not be deleted.- Specified by:
clearExpireAsyncin interfaceRExpirableAsync- Returns:
trueif the timeout was cleared andfalseif not
-
moveAsync
public RFuture<Boolean> moveAsync(int database)
Description copied from interface:RObjectAsyncMove object to another database in async mode- Specified by:
moveAsyncin interfaceRObjectAsync- Overrides:
moveAsyncin classRedissonObject- Parameters:
database- - number of Redis database- Returns:
trueif key was movedfalseif not
-
migrateAsync
public RFuture<Void> migrateAsync(String host, int port, int database, long timeout)
Description copied from interface:RObjectAsyncTransfer object from source Redis instance to destination Redis instance in async mode- Specified by:
migrateAsyncin interfaceRObjectAsync- Overrides:
migrateAsyncin 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:RBucketAsyncReturns size of object in bytes- Specified by:
sizeAsyncin interfaceRBucketAsync<V>- Overrides:
sizeAsyncin classRedissonBucket<V>- Returns:
- object size
-
isExistsAsync
public RFuture<Boolean> isExistsAsync()
Description copied from interface:RObjectAsyncCheck object existence in async mode.- Specified by:
isExistsAsyncin interfaceRObjectAsync- Overrides:
isExistsAsyncin classRedissonObject- Returns:
trueif object exists andfalseotherwise
-
touchAsync
public RFuture<Boolean> touchAsync()
Description copied from interface:RObjectAsyncUpdate the last access time of an object in async mode.- Specified by:
touchAsyncin interfaceRObjectAsync- Overrides:
touchAsyncin classRedissonObject- Returns:
trueif object was touched elsefalse
-
unlinkAsync
public RFuture<Boolean> unlinkAsync()
Description copied from interface:RObjectAsyncDelete the objects. Actual removal will happen later asynchronously.Requires Redis 4.0+
- Specified by:
unlinkAsyncin interfaceRObjectAsync- Overrides:
unlinkAsyncin classRedissonObject- Returns:
trueif it was exist and deleted elsefalse
-
deleteAsync
public RFuture<Boolean> deleteAsync()
Description copied from interface:RObjectAsyncDelete object in async mode- Specified by:
deleteAsyncin interfaceRObjectAsync- Overrides:
deleteAsyncin classRedissonObject- Returns:
trueif object was deletedfalseif not
-
getAsync
public RFuture<V> getAsync()
Description copied from interface:RBucketAsyncRetrieves element stored in the holder.- Specified by:
getAsyncin interfaceRBucketAsync<V>- Overrides:
getAsyncin classRedissonBucket<V>- Returns:
- element
-
compareAndSetAsync
public RFuture<Boolean> compareAndSetAsync(V expect, V update)
Description copied from interface:RBucketAsyncAtomically 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:
compareAndSetAsyncin interfaceRBucketAsync<V>- Overrides:
compareAndSetAsyncin classRedissonBucket<V>- Parameters:
expect- the expected valueupdate- the new value- Returns:
trueif successful; orfalseif 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:RBucketAsyncRetrieves current element in the holder and replaces it withnewValuewith definedtimeToLiveinterval.- Specified by:
getAndSetAsyncin interfaceRBucketAsync<V>- Overrides:
getAndSetAsyncin 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:RBucketAsyncRetrieves current element in the holder and replaces it withnewValue.- Specified by:
getAndSetAsyncin interfaceRBucketAsync<V>- Overrides:
getAndSetAsyncin classRedissonBucket<V>- Parameters:
value- - value to set- Returns:
- previous value
-
getAndDeleteAsync
public RFuture<V> getAndDeleteAsync()
Description copied from interface:RBucketAsyncRetrieves element in the holder and removes it.- Specified by:
getAndDeleteAsyncin interfaceRBucketAsync<V>- Overrides:
getAndDeleteAsyncin classRedissonBucket<V>- Returns:
- element
-
setAsync
public RFuture<Void> setAsync(V newValue)
Description copied from interface:RBucketAsyncStores element into the holder.- Specified by:
setAsyncin interfaceRBucketAsync<V>- Overrides:
setAsyncin classRedissonBucket<V>- Parameters:
newValue- - value to set- Returns:
- void
-
setAsync
public RFuture<Void> setAsync(V value, long timeToLive, TimeUnit timeUnit)
Description copied from interface:RBucketAsyncStores element into the holder with definedtimeToLiveinterval.- Specified by:
setAsyncin interfaceRBucketAsync<V>- Overrides:
setAsyncin 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:RBucketAsyncTries to set element atomically into empty holder.- Specified by:
trySetAsyncin interfaceRBucketAsync<V>- Overrides:
trySetAsyncin classRedissonBucket<V>- Parameters:
newValue- - value to set- Returns:
trueif successful, orfalseif element was already set
-
trySetAsync
public RFuture<Boolean> trySetAsync(V value, long timeToLive, TimeUnit timeUnit)
Description copied from interface:RBucketAsyncTries to set element atomically into empty holder with definedtimeToLiveinterval.- Specified by:
trySetAsyncin interfaceRBucketAsync<V>- Overrides:
trySetAsyncin classRedissonBucket<V>- Parameters:
value- - value to settimeToLive- - time to live intervaltimeUnit- - unit of time to live interval- Returns:
trueif successful, orfalseif element was already set
-
checkState
protected void checkState()
-
expire
public boolean expire(long timeToLive, TimeUnit timeUnit)Description copied from interface:RExpirableSet a timeout for object. After the timeout has expired, the key will automatically be deleted.- Specified by:
expirein interfaceRExpirable- Parameters:
timeToLive- - timeout before object will be deletedtimeUnit- - timeout time unit- Returns:
trueif the timeout was set andfalseif not
-
expireAt
public boolean expireAt(long timestamp)
Description copied from interface:RExpirableUseRExpirable.expire(Instant)instead- Specified by:
expireAtin interfaceRExpirable- Parameters:
timestamp- - expire date in milliseconds (Unix timestamp)- Returns:
trueif the timeout was set andfalseif not
-
expire
public boolean expire(Instant instant)
Description copied from interface:RExpirableSet an expire date for object. When expire date comes the key will automatically be deleted.- Specified by:
expirein interfaceRExpirable- Parameters:
instant- - expire date- Returns:
trueif the timeout was set andfalseif not
-
expireAt
public boolean expireAt(Date timestamp)
Description copied from interface:RExpirableUseRExpirable.expire(Instant)instead- Specified by:
expireAtin interfaceRExpirable- Parameters:
timestamp- - expire date- Returns:
trueif the timeout was set andfalseif not
-
clearExpire
public boolean clearExpire()
Description copied from interface:RExpirableClear an expire timeout or expire date for object.- Specified by:
clearExpirein interfaceRExpirable- Returns:
trueif timeout was removedfalseif object does not exist or does not have an associated timeout
-
remainTimeToLive
public long remainTimeToLive()
Description copied from interface:RExpirableRemaining time to live of Redisson object that has a timeout- Specified by:
remainTimeToLivein 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:RExpirableAsyncRemaining time to live of Redisson object that has a timeout- Specified by:
remainTimeToLiveAsyncin 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)
-
-