
Public Member Functions | |
| T | cas (final String key, final T initial, int initialExp, final CASMutation< T > m) throws Exception |
| CASMutator (MemcachedClient c, Transcoder< T > tc) | |
| CASMutator (MemcachedClient c, Transcoder< T > tc, int max_tries) | |
Private Attributes | |
| final MemcachedClient | client |
| final int | max |
| final Transcoder< T > | transcoder |
Static Private Attributes | |
| static final int | MAX_TRIES = 8192 |
Example usage (reinventing incr):
// Get or create a client. MemcachedClient client=[...];
// Get a Transcoder. Transcoder<Long> tc = 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);
| CASMutator | ( | MemcachedClient | c, | |
| Transcoder< T > | tc, | |||
| int | max_tries | |||
| ) |
Construct a CASMutator that uses the given client.
| c | the client | |
| tc | the Transcoder to use | |
| max_tries | the maximum number of attempts to get a CAS to succeed |
| CASMutator | ( | MemcachedClient | c, | |
| Transcoder< T > | tc | |||
| ) |
Construct a CASMutator that uses the given client.
| c | the client | |
| tc | the Transcoder to use | |
| max_tries | the maximum number of attempts to get a CAS to succeed |
| T cas | ( | final String | key, | |
| final T | initial, | |||
| int | initialExp, | |||
| final CASMutation< T > | m | |||
| ) | throws Exception |
CAS a new value in for a key.
| key | the key to be CASed | |
| initial | the value to use when the object is not cached | |
| initialExp | the expiration time to use when initializing | |
| m | the mutation to perform on an object if a value exists for the key |
final MemcachedClient client [private] |
final int max [private] |
final int MAX_TRIES = 8192 [static, private] |
final Transcoder<T> transcoder [private] |
1.5.8