Package net.rubyeye.xmemcached
Class Counter
- java.lang.Object
-
- net.rubyeye.xmemcached.Counter
-
public final class Counter extends Object
Counter,encapsulate the incr/decr methods.- Author:
- dennis
-
-
Constructor Summary
Constructors Constructor Description Counter(MemcachedClient memcachedClient, String key, long initialValue)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longaddAndGet(long delta)Add value and get the resultlongdecrementAndGet()Decrease value by onebooleanequals(Object obj)longget()Get current valueStringgetKey()inthashCode()longincrementAndGet()Increase value by onevoidset(long value)Set counter's value to expected.
-
-
-
Constructor Detail
-
Counter
public Counter(MemcachedClient memcachedClient, String key, long initialValue)
-
-
Method Detail
-
getKey
public final String getKey()
-
get
public long get() throws MemcachedException, InterruptedException, TimeoutExceptionGet current value- Returns:
- Throws:
MemcachedExceptionInterruptedExceptionTimeoutException
-
set
public void set(long value) throws MemcachedException, InterruptedException, TimeoutExceptionSet counter's value to expected.- Parameters:
value-- Throws:
MemcachedExceptionInterruptedExceptionTimeoutException
-
incrementAndGet
public long incrementAndGet() throws MemcachedException, InterruptedException, TimeoutExceptionIncrease value by one- Returns:
- Throws:
MemcachedExceptionInterruptedExceptionTimeoutException
-
decrementAndGet
public long decrementAndGet() throws MemcachedException, InterruptedException, TimeoutExceptionDecrease value by one- Returns:
- Throws:
MemcachedExceptionInterruptedExceptionTimeoutException
-
addAndGet
public long addAndGet(long delta) throws MemcachedException, InterruptedException, TimeoutExceptionAdd value and get the result- Parameters:
delta-- Returns:
- Throws:
MemcachedExceptionInterruptedExceptionTimeoutException
-
-