|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.spy.memcached.compat.SpyObject
net.spy.memcached.CASMutator<T>
public class CASMutator<T>
Object that provides mutation via CAS over a given memcache client.
Example usage (reinventing incr):
// Get or create a client. MemcachedClient client=[...]; // Get a Transcoder. Transcodertc = new LongTranscoder(); // Get a mutator instance that uses that client. CASMutator<Long> mutator=new CASMutator<Long>(client, tc); // Get a mutation that knows what to do when a value is found. CASMutation<Long> mutation=new CASMutation<Long>() { public Long getNewValue(Long current) { return current + 1; } }; // Do a mutation. long currentValue=mutator.cas(someKey, 0L, 0, mutation);
| Constructor Summary | |
|---|---|
CASMutator(MemcachedClientIF c,
Transcoder<T> tc)
Construct a CASMutator that uses the given client. |
|
CASMutator(MemcachedClientIF c,
Transcoder<T> tc,
int maxTries)
Construct a CASMutator that uses the given client. |
|
| Method Summary | |
|---|---|
T |
cas(java.lang.String key,
T initial,
int initialExp,
CASMutation<T> m)
CAS a new value in for a key. |
| Methods inherited from class net.spy.memcached.compat.SpyObject |
|---|
getLogger |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CASMutator(MemcachedClientIF c,
Transcoder<T> tc,
int maxTries)
c - the clienttc - the Transcoder to usemaxTries - the maximum number of attempts to get a CAS to succeed
public CASMutator(MemcachedClientIF c,
Transcoder<T> tc)
c - the clienttc - the Transcoder to use| Method Detail |
|---|
public T cas(java.lang.String key,
T initial,
int initialExp,
CASMutation<T> m)
throws java.lang.Exception
Note that if initial is null, this method will only update existing values.
key - the key to be CASedinitial - the value to use when the object is not cachedinitialExp - the expiration time to use when initializingm - the mutation to perform on an object if a value exists for the key
java.lang.Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||