|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Number org.springframework.data.redis.support.atomic.RedisAtomicInteger
public class RedisAtomicInteger
Atomic integer backed by Redis. Uses Redis atomic increment/decrement and watch/multi/exec operations for CAS operations.
AtomicInteger
,
Serialized FormConstructor Summary | |
---|---|
RedisAtomicInteger(String redisCounter,
RedisConnectionFactory factory)
Constructs a new RedisAtomicInteger instance. |
|
RedisAtomicInteger(String redisCounter,
RedisConnectionFactory factory,
int initialValue)
Constructs a new RedisAtomicInteger instance. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Number |
---|
byteValue, shortValue |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public RedisAtomicInteger(String redisCounter, RedisConnectionFactory factory)
RedisAtomicInteger
instance.
redisCounter
- redis counterfactory
- connection factorypublic RedisAtomicInteger(String redisCounter, RedisConnectionFactory factory, int initialValue)
RedisAtomicInteger
instance.
redisCounter
- factory
- initialValue
- Method Detail |
---|
public int get()
public void set(int newValue)
newValue
- the new valuepublic int getAndSet(int newValue)
newValue
- the new value
public boolean compareAndSet(int expect, int update)
expect
- the expected valueupdate
- the new value
public int getAndIncrement()
public int getAndDecrement()
public int getAndAdd(int delta)
delta
- the value to add
public int incrementAndGet()
public int decrementAndGet()
public int addAndGet(int delta)
delta
- the value to add
public String toString()
toString
in class Object
public int intValue()
intValue
in class Number
public long longValue()
longValue
in class Number
public float floatValue()
floatValue
in class Number
public double doubleValue()
doubleValue
in class Number
public String getKey()
BoundKeyOperations
getKey
in interface BoundKeyOperations<String>
public Boolean expire(long timeout, TimeUnit unit)
BoundKeyOperations
expire
in interface BoundKeyOperations<String>
timeout
- expiration valueunit
- expiration unit
public Boolean expireAt(Date date)
BoundKeyOperations
expireAt
in interface BoundKeyOperations<String>
date
- expiration date
public Long getExpire()
BoundKeyOperations
getExpire
in interface BoundKeyOperations<String>
public Boolean persist()
BoundKeyOperations
persist
in interface BoundKeyOperations<String>
public void rename(String newKey)
BoundKeyOperations
rename
in interface BoundKeyOperations<String>
newKey
- new keypublic DataType getType()
BoundKeyOperations
getType
in interface BoundKeyOperations<String>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |