public class RedisAtomicDouble extends Number implements Serializable, BoundKeyOperations<String>
| Constructor and Description |
|---|
RedisAtomicDouble(String redisCounter,
RedisConnectionFactory factory)
Constructs a new
RedisAtomicDouble instance. |
RedisAtomicDouble(String redisCounter,
RedisConnectionFactory factory,
double initialValue)
Constructs a new
RedisAtomicDouble instance. |
RedisAtomicDouble(String redisCounter,
RedisOperations<String,Double> template)
Constructs a new
RedisAtomicDouble instance. |
RedisAtomicDouble(String redisCounter,
RedisOperations<String,Double> template,
double initialValue)
Constructs a new
RedisAtomicDouble instance. |
| Modifier and Type | Method and Description |
|---|---|
double |
addAndGet(double delta)
Atomically adds the given value to the current value.
|
boolean |
compareAndSet(double expect,
double update)
Atomically sets the value to the given updated value if the current value
== the expected value. |
double |
decrementAndGet()
Atomically decrements by one the current value.
|
double |
doubleValue() |
Boolean |
expire(long timeout,
TimeUnit unit)
Sets the key time-to-live/expiration.
|
Boolean |
expireAt(Date date)
Sets the key time-to-live/expiration.
|
float |
floatValue() |
double |
get()
Gets the current value.
|
double |
getAndAdd(double delta)
Atomically adds the given value to the current value.
|
double |
getAndDecrement()
Atomically decrements by one the current value.
|
double |
getAndIncrement()
Atomically increments by one the current value.
|
double |
getAndSet(double newValue)
Atomically sets to the given value and returns the old value.
|
Long |
getExpire()
Returns the expiration of this key.
|
String |
getKey()
Returns the key associated with this entity.
|
DataType |
getType()
Returns the associated Redis type.
|
double |
incrementAndGet()
Atomically increments by one the current value.
|
int |
intValue() |
long |
longValue() |
Boolean |
persist()
Removes the expiration (if any) of the key.
|
void |
rename(String newKey)
Renames the key.
|
void |
set(double newValue)
Sets to the given value.
|
String |
toString()
Returns the String representation of the current value.
|
byteValue, shortValuepublic RedisAtomicDouble(String redisCounter, RedisConnectionFactory factory)
RedisAtomicDouble instance. Uses the value existing in Redis or 0 if none is found.redisCounter - redis counterfactory - connection factorypublic RedisAtomicDouble(String redisCounter, RedisConnectionFactory factory, double initialValue)
RedisAtomicDouble instance.redisCounter - factory - initialValue - public RedisAtomicDouble(String redisCounter, RedisOperations<String,Double> template)
RedisAtomicDouble instance. Uses the value existing in Redis or 0 if none is found.redisCounter - the redis countertemplate - the templateRedisAtomicDouble(String, RedisConnectionFactory, double)public RedisAtomicDouble(String redisCounter, RedisOperations<String,Double> template, double initialValue)
RedisAtomicDouble instance. Note: You need to configure the given template
with appropriate RedisSerializer for the key and value. As an alternative one could use the
RedisAtomicDouble(String, RedisConnectionFactory, Double) constructor which uses appropriate default
serializers.redisCounter - the redis countertemplate - the templateinitialValue - the initial valuepublic double get()
public void set(double newValue)
newValue - the new valuepublic double getAndSet(double newValue)
newValue - the new valuepublic boolean compareAndSet(double expect,
double update)
== the expected value.expect - the expected valueupdate - the new valuepublic double getAndIncrement()
public double getAndDecrement()
public double getAndAdd(double delta)
delta - the value to addpublic double incrementAndGet()
public double decrementAndGet()
public double addAndGet(double delta)
delta - the value to addpublic String toString()
public String getKey()
BoundKeyOperationsgetKey in interface BoundKeyOperations<String>public DataType getType()
BoundKeyOperationsgetType in interface BoundKeyOperations<String>public Long getExpire()
BoundKeyOperationsgetExpire in interface BoundKeyOperations<String>public Boolean expire(long timeout, TimeUnit unit)
BoundKeyOperationsexpire in interface BoundKeyOperations<String>timeout - expiration valueunit - expiration unitpublic Boolean expireAt(Date date)
BoundKeyOperationsexpireAt in interface BoundKeyOperations<String>date - expiration datepublic Boolean persist()
BoundKeyOperationspersist in interface BoundKeyOperations<String>public void rename(String newKey)
BoundKeyOperationsrename in interface BoundKeyOperations<String>newKey - new keypublic double doubleValue()
doubleValue in class Numberpublic float floatValue()
floatValue in class Number