public class RedisAtomicInteger extends Number implements Serializable, BoundKeyOperations<String>
AtomicInteger,
Serialized Form| Constructor and Description |
|---|
RedisAtomicInteger(String redisCounter,
RedisConnectionFactory factory)
Constructs a new
RedisAtomicInteger instance. |
RedisAtomicInteger(String redisCounter,
RedisConnectionFactory factory,
int initialValue)
Constructs a new
RedisAtomicInteger instance. |
RedisAtomicInteger(String redisCounter,
RedisOperations<String,Integer> template)
Constructs a new
RedisAtomicInteger instance. |
RedisAtomicInteger(String redisCounter,
RedisOperations<String,Integer> template,
int initialValue)
Constructs a new
RedisAtomicInteger instance. |
| Modifier and Type | Method and Description |
|---|---|
int |
addAndGet(int delta)
Atomically add the given value to current value.
|
boolean |
compareAndSet(int expect,
int update)
Atomically set the value to the given updated value if the current value == the expected value.
|
int |
decrementAndGet()
Atomically decrement 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() |
int |
get()
Get the current value.
|
int |
getAndAdd(int delta)
Atomically add the given value to current value.
|
int |
getAndDecrement()
Atomically decrement by one the current value.
|
int |
getAndIncrement()
Atomically increment by one the current value.
|
int |
getAndSet(int newValue)
Set to the give value and return 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.
|
int |
incrementAndGet()
Atomically increment 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(int newValue)
Set to the given value.
|
String |
toString()
Returns the String representation of the current value.
|
byteValue, shortValuepublic RedisAtomicInteger(String redisCounter, RedisConnectionFactory factory)
RedisAtomicInteger instance. Uses the value existing in Redis or 0 if none is found.redisCounter - redis counterfactory - connection factorypublic RedisAtomicInteger(String redisCounter, RedisConnectionFactory factory, int initialValue)
RedisAtomicInteger instance.redisCounter - the redis counterfactory - the factoryinitialValue - the initial valuepublic RedisAtomicInteger(String redisCounter, RedisOperations<String,Integer> template)
RedisAtomicInteger instance. Uses the value existing in Redis or 0 if none is found.redisCounter - the redis countertemplate - the templatepublic RedisAtomicInteger(String redisCounter, RedisOperations<String,Integer> template, int initialValue)
RedisAtomicInteger instance.redisCounter - the redis countertemplate - the templateinitialValue - the initial valuepublic int get()
public void set(int newValue)
newValue - the new valuepublic int getAndSet(int newValue)
newValue - the new valuepublic boolean compareAndSet(int expect,
int update)
expect - the expected valueupdate - the new valuepublic int getAndIncrement()
public int getAndDecrement()
public int getAndAdd(int delta)
delta - the value to addpublic int incrementAndGet()
public int decrementAndGet()
public int addAndGet(int delta)
delta - the value to addpublic String toString()
public float floatValue()
floatValue in class Numberpublic double doubleValue()
doubleValue in class Numberpublic String getKey()
BoundKeyOperationsgetKey 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 Long getExpire()
BoundKeyOperationsgetExpire in interface BoundKeyOperations<String>public Boolean persist()
BoundKeyOperationspersist in interface BoundKeyOperations<String>public void rename(String newKey)
BoundKeyOperationsrename in interface BoundKeyOperations<String>newKey - new keypublic DataType getType()
BoundKeyOperationsgetType in interface BoundKeyOperations<String>