Package org.redisson
Class RedissonAtomicDouble
- java.lang.Object
-
- org.redisson.RedissonObject
-
- org.redisson.RedissonAtomicDouble
-
- All Implemented Interfaces:
RAtomicDouble,RAtomicDoubleAsync,RExpirable,RExpirableAsync,RObject,RObjectAsync
public class RedissonAtomicDouble extends RedissonObject implements RAtomicDouble
Distributed alternative to theAtomicLong- Author:
- Nikita Koksharov
-
-
Field Summary
-
Fields inherited from class org.redisson.RedissonObject
codec, commandExecutor, name
-
-
Constructor Summary
Constructors Constructor Description RedissonAtomicDouble(CommandAsyncExecutor commandExecutor, String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doubleaddAndGet(double delta)Atomically adds the given value to the current value.RFuture<Double>addAndGetAsync(double delta)Atomically adds the given value to the current value.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)booleancompareAndSet(double expect, double update)Atomically sets the value to the given updated value only if the current value==the expected value.RFuture<Boolean>compareAndSetAsync(double expect, double update)Atomically sets the value to the given updated value only if the current value==the expected value.doubledecrementAndGet()Atomically decrements the current value by one.RFuture<Double>decrementAndGetAsync()Atomically decrements the current value by one.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 instant)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)insteaddoubleget()Returns current value.doublegetAndAdd(double delta)Atomically adds the given value to the current value.RFuture<Double>getAndAddAsync(double delta)Atomically adds the given value to the current value.doublegetAndDecrement()Atomically decrements by one the current value.RFuture<Double>getAndDecrementAsync()Atomically decrements by one the current value.doublegetAndDelete()Returns and deletes objectRFuture<Double>getAndDeleteAsync()Returns and deletes objectdoublegetAndIncrement()Atomically increments the current value by one.RFuture<Double>getAndIncrementAsync()Atomically increments the current value by one.doublegetAndSet(double newValue)Atomically sets the given value and returns the old value.RFuture<Double>getAndSetAsync(double newValue)Atomically sets the given value and returns the old value.RFuture<Double>getAsync()Returns current value.doubleincrementAndGet()Atomically increments the current value by one.RFuture<Double>incrementAndGetAsync()Atomically increments the current value by one.longremainTimeToLive()Remaining time to live of Redisson object that has a timeoutRFuture<Long>remainTimeToLiveAsync()Remaining time to live of Redisson object that has a timeoutvoidset(double newValue)Atomically sets the given value.RFuture<Void>setAsync(double newValue)Atomically sets the given value.StringtoString()-
Methods inherited from class org.redisson.RedissonObject
addListener, addListener, addListenerAsync, addListenerAsync, copy, copyAsync, delete, deleteAsync, deleteAsync, dump, dumpAsync, encode, encode, encode, encode, encodeMapKey, encodeMapKeys, encodeMapValue, encodeMapValues, get, getCodec, getIdleTime, getIdleTimeAsync, getLockByMapKey, getLockByValue, getName, getRawName, getRawName, isExists, isExistsAsync, migrate, migrateAsync, move, moveAsync, prefixName, removeListener, removeListenerAsync, removeListenersAsync, rename, renameAsync, renamenx, renamenxAsync, restore, restore, restoreAndReplace, restoreAndReplace, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, setName, sizeInMemory, sizeInMemoryAsync, sizeInMemoryAsync, sizeInMemoryAsync, suffixName, toSeconds, toStream, touch, touchAsync, unlink, unlinkAsync
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, 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
clearExpireAsync, expireAsync, expireAsync, expireAtAsync, expireAtAsync, remainTimeToLiveAsync
-
Methods inherited from interface org.redisson.api.RObject
addListener, copy, delete, dump, getCodec, getIdleTime, getName, isExists, migrate, move, removeListener, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, sizeInMemory, touch, unlink
-
Methods inherited from interface org.redisson.api.RObjectAsync
addListenerAsync, copyAsync, deleteAsync, dumpAsync, getIdleTimeAsync, isExistsAsync, migrateAsync, moveAsync, removeListenerAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemoryAsync, touchAsync, unlinkAsync
-
-
-
-
Constructor Detail
-
RedissonAtomicDouble
public RedissonAtomicDouble(CommandAsyncExecutor commandExecutor, String name)
-
-
Method Detail
-
addAndGet
public double addAndGet(double delta)
Description copied from interface:RAtomicDoubleAtomically adds the given value to the current value.- Specified by:
addAndGetin interfaceRAtomicDouble- Parameters:
delta- the value to add- Returns:
- the updated value
-
addAndGetAsync
public RFuture<Double> addAndGetAsync(double delta)
Description copied from interface:RAtomicDoubleAsyncAtomically adds the given value to the current value.- Specified by:
addAndGetAsyncin interfaceRAtomicDoubleAsync- Parameters:
delta- the value to add- Returns:
- the updated value
-
compareAndSet
public boolean compareAndSet(double expect, double update)Description copied from interface:RAtomicDoubleAtomically sets the value to the given updated value only if the current value==the expected value.- Specified by:
compareAndSetin interfaceRAtomicDouble- Parameters:
expect- the expected valueupdate- the new value- Returns:
- true if successful; or false if the actual value was not equal to the expected value.
-
compareAndSetAsync
public RFuture<Boolean> compareAndSetAsync(double expect, double update)
Description copied from interface:RAtomicDoubleAsyncAtomically sets the value to the given updated value only if the current value==the expected value.- Specified by:
compareAndSetAsyncin interfaceRAtomicDoubleAsync- Parameters:
expect- the expected valueupdate- the new value- Returns:
- true if successful; or false if the actual value was not equal to the expected value.
-
decrementAndGet
public double decrementAndGet()
Description copied from interface:RAtomicDoubleAtomically decrements the current value by one.- Specified by:
decrementAndGetin interfaceRAtomicDouble- Returns:
- the updated value
-
decrementAndGetAsync
public RFuture<Double> decrementAndGetAsync()
Description copied from interface:RAtomicDoubleAsyncAtomically decrements the current value by one.- Specified by:
decrementAndGetAsyncin interfaceRAtomicDoubleAsync- Returns:
- the updated value
-
get
public double get()
Description copied from interface:RAtomicDoubleReturns current value.- Specified by:
getin interfaceRAtomicDouble- Returns:
- current value
-
getAndDelete
public double getAndDelete()
Description copied from interface:RAtomicDoubleReturns and deletes object- Specified by:
getAndDeletein interfaceRAtomicDouble- Returns:
- the current value
-
getAndDeleteAsync
public RFuture<Double> getAndDeleteAsync()
Description copied from interface:RAtomicDoubleAsyncReturns and deletes object- Specified by:
getAndDeleteAsyncin interfaceRAtomicDoubleAsync- Returns:
- the current value
-
getAsync
public RFuture<Double> getAsync()
Description copied from interface:RAtomicDoubleAsyncReturns current value.- Specified by:
getAsyncin interfaceRAtomicDoubleAsync- Returns:
- current value
-
getAndAdd
public double getAndAdd(double delta)
Description copied from interface:RAtomicDoubleAtomically adds the given value to the current value.- Specified by:
getAndAddin interfaceRAtomicDouble- Parameters:
delta- the value to add- Returns:
- the old value before the add
-
getAndAddAsync
public RFuture<Double> getAndAddAsync(double delta)
Description copied from interface:RAtomicDoubleAsyncAtomically adds the given value to the current value.- Specified by:
getAndAddAsyncin interfaceRAtomicDoubleAsync- Parameters:
delta- the value to add- Returns:
- the updated value
-
getAndSet
public double getAndSet(double newValue)
Description copied from interface:RAtomicDoubleAtomically sets the given value and returns the old value.- Specified by:
getAndSetin interfaceRAtomicDouble- Parameters:
newValue- the new value- Returns:
- the old value
-
getAndSetAsync
public RFuture<Double> getAndSetAsync(double newValue)
Description copied from interface:RAtomicDoubleAsyncAtomically sets the given value and returns the old value.- Specified by:
getAndSetAsyncin interfaceRAtomicDoubleAsync- Parameters:
newValue- the new value- Returns:
- the old value
-
incrementAndGet
public double incrementAndGet()
Description copied from interface:RAtomicDoubleAtomically increments the current value by one.- Specified by:
incrementAndGetin interfaceRAtomicDouble- Returns:
- the updated value
-
incrementAndGetAsync
public RFuture<Double> incrementAndGetAsync()
Description copied from interface:RAtomicDoubleAsyncAtomically increments the current value by one.- Specified by:
incrementAndGetAsyncin interfaceRAtomicDoubleAsync- Returns:
- the updated value
-
getAndIncrement
public double getAndIncrement()
Description copied from interface:RAtomicDoubleAtomically increments the current value by one.- Specified by:
getAndIncrementin interfaceRAtomicDouble- Returns:
- the old value
-
getAndIncrementAsync
public RFuture<Double> getAndIncrementAsync()
Description copied from interface:RAtomicDoubleAsyncAtomically increments the current value by one.- Specified by:
getAndIncrementAsyncin interfaceRAtomicDoubleAsync- Returns:
- the old value
-
getAndDecrement
public double getAndDecrement()
Description copied from interface:RAtomicDoubleAtomically decrements by one the current value.- Specified by:
getAndDecrementin interfaceRAtomicDouble- Returns:
- the previous value
-
getAndDecrementAsync
public RFuture<Double> getAndDecrementAsync()
Description copied from interface:RAtomicDoubleAsyncAtomically decrements by one the current value.- Specified by:
getAndDecrementAsyncin interfaceRAtomicDoubleAsync- Returns:
- the previous value
-
set
public void set(double newValue)
Description copied from interface:RAtomicDoubleAtomically sets the given value.- Specified by:
setin interfaceRAtomicDouble- Parameters:
newValue- the new value
-
setAsync
public RFuture<Void> setAsync(double newValue)
Description copied from interface:RAtomicDoubleAsyncAtomically sets the given value.- Specified by:
setAsyncin interfaceRAtomicDoubleAsync- Parameters:
newValue- the new value- Returns:
- void
-
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
-
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
-
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
-
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
-
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
-
expireAsync
public RFuture<Boolean> expireAsync(Instant instant)
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:
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
-
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
-
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
-
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
-
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)
-
-