V - The value type for all operationspublic class DefaultBinaryMemcacheClient<V> extends Object implements BinaryMemcacheClient<V>
BinaryMemcacheClient| Modifier and Type | Field and Description |
|---|---|
private Charset |
charset |
private Metrics |
metrics |
private RawMemcacheClient |
rawMemcacheClient |
private TransformerUtil<V> |
transformerUtil |
private Transcoder<V> |
valueTranscoder |
| Constructor and Description |
|---|
DefaultBinaryMemcacheClient(RawMemcacheClient rawMemcacheClient,
Metrics metrics,
Transcoder<V> valueTranscoder,
Charset charset) |
| Modifier and Type | Method and Description |
|---|---|
com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> |
add(String key,
V value,
int ttl)
Add a key in memcache with the provided value, with the specified TTL.
|
com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> |
add(String key,
V value,
int ttl,
long cas)
Add a key in memcache with the provided value, with the specified TTL.
|
com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> |
append(String key,
V value) |
com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> |
append(String key,
V value,
long cas) |
com.google.common.util.concurrent.ListenableFuture<List<GetResult<V>>> |
casGet(List<String> keys)
Get the value for the provided keys
|
com.google.common.util.concurrent.ListenableFuture<GetResult<V>> |
casGet(String key)
Get the value for the provided key, including the CAS value
|
com.google.common.util.concurrent.ListenableFuture<GetResult<V>> |
casGetAndTouch(String key,
int ttl)
Get the value for the provided key, including the CAS value, and sets the expiration
|
private com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> |
casSetInternal(byte opcode,
String key,
V value,
int ttl,
long cas) |
com.google.common.util.concurrent.ListenableFuture<Long> |
decr(String key,
long by,
long initial,
int ttl)
Decrement a counter for the provided key
|
com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> |
delete(String key)
Delete the provided key
|
com.google.common.util.concurrent.ListenableFuture<List<V>> |
get(List<String> keys)
Get the value for the provided keys
|
com.google.common.util.concurrent.ListenableFuture<V> |
get(String key)
Get the value for the provided key
|
com.google.common.util.concurrent.ListenableFuture<List<V>> |
getAndTouch(List<String> keys,
int ttl)
Get the values for the provided keys and sets the expiration
|
com.google.common.util.concurrent.ListenableFuture<V> |
getAndTouch(String key,
int ttl)
Get the value for the provided key and sets the expiration
|
private com.google.common.util.concurrent.ListenableFuture<GetResult<V>> |
getInternal(String key,
int ttl) |
com.google.common.util.concurrent.ListenableFuture<Long> |
incr(String key,
long by,
long initial,
int ttl)
Increment a counter for the provided key
|
private com.google.common.util.concurrent.ListenableFuture<Long> |
incrInternal(byte opcode,
String key,
long by,
long initial,
int ttl) |
boolean |
isConnected()
Is the client connected to a server?
|
private com.google.common.util.concurrent.ListenableFuture<List<GetResult<V>>> |
multiget(List<String> keys,
int ttl) |
com.google.common.util.concurrent.ListenableFuture<Void> |
noop()
Send a noop request
|
int |
numActiveConnections()
How many active socket connections do we have (i.e.
|
int |
numTotalConnections()
How many actual socket connections do we have, including currently disconnected clients.
|
com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> |
prepend(String key,
V value) |
com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> |
prepend(String key,
V value,
long cas) |
void |
registerForConnectionChanges(ConnectionChangeListener listener)
Register for connection change events.
|
com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> |
replace(String key,
V value,
int ttl)
Replace a key in memcache with the provided value, with the specified TTL.
|
com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> |
replace(String key,
V value,
int ttl,
long cas)
Replace a key in memcache with the provided value, with the specified TTL.
|
com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> |
set(String key,
V value,
int ttl)
Set a key in memcache to the provided value, with the specified TTL
|
com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> |
set(String key,
V value,
int ttl,
long cas)
Compare and set a key in memcache to the provided value, with the specified TTL
|
private com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> |
setInternal(byte opcode,
String key,
V value,
int ttl) |
void |
shutdown()
Shut down the client.
|
String |
toString() |
com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> |
touch(String key,
int ttl)
Sets the expiration for the provided key
|
void |
unregisterForConnectionChanges(ConnectionChangeListener listener)
Unregister the provided listener so that it no longer receives connection change
callbacks.
|
private final RawMemcacheClient rawMemcacheClient
private final Metrics metrics
private final Transcoder<V> valueTranscoder
private final TransformerUtil<V> transformerUtil
private final Charset charset
public DefaultBinaryMemcacheClient(RawMemcacheClient rawMemcacheClient, Metrics metrics, Transcoder<V> valueTranscoder, Charset charset)
public com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> set(String key, V value, int ttl)
MemcacheClientset in interface MemcacheClient<V>key - The key, must not be nullvalue - The value, must not be nullttl - The TTL in secondspublic com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> set(String key, V value, int ttl, long cas)
MemcacheClientset in interface MemcacheClient<V>key - The key, must not be nullvalue - The value, must not be nullttl - The TTL in secondscas - The CAS value, must match the value on the server for the set to go throughpublic com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> add(String key, V value, int ttl)
MemcacheClientadd in interface MemcacheClient<V>key - The key, must not be nullvalue - The value, must not be nullttl - The TTL in secondspublic com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> replace(String key, V value, int ttl)
MemcacheClientreplace in interface MemcacheClient<V>key - The key, must not be nullvalue - The value, must not be nullttl - The TTL in secondsprivate com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> setInternal(byte opcode, String key, V value, int ttl)
public com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> add(String key, V value, int ttl, long cas)
BinaryMemcacheClientadd in interface BinaryMemcacheClient<V>key - The key, must not be nullvalue - The value, must not be nullttl - The TTL in secondscas - The CAS value, must match the value on the server for the set to go throughpublic com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> replace(String key, V value, int ttl, long cas)
BinaryMemcacheClientreplace in interface BinaryMemcacheClient<V>key - The key, must not be nullvalue - The value, must not be nullttl - The TTL in secondscas - The CAS value, must match the value on the server for the set to go throughprivate com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> casSetInternal(byte opcode, String key, V value, int ttl, long cas)
public com.google.common.util.concurrent.ListenableFuture<V> get(String key)
MemcacheClientget in interface MemcacheClient<V>key - The key, must not be nullpublic com.google.common.util.concurrent.ListenableFuture<V> getAndTouch(String key, int ttl)
BinaryMemcacheClientgetAndTouch in interface BinaryMemcacheClient<V>key - The key, must not be nullttl - The TTL in secondspublic com.google.common.util.concurrent.ListenableFuture<List<V>> get(List<String> keys)
MemcacheClientget in interface MemcacheClient<V>keys - Keys, must not be null, nor must any key in the listpublic com.google.common.util.concurrent.ListenableFuture<GetResult<V>> casGet(String key)
MemcacheClientcasGet in interface MemcacheClient<V>key - First key, must not be nullprivate com.google.common.util.concurrent.ListenableFuture<GetResult<V>> getInternal(String key, int ttl)
public com.google.common.util.concurrent.ListenableFuture<List<GetResult<V>>> casGet(List<String> keys)
MemcacheClientcasGet in interface MemcacheClient<V>keys - Keys, must not be null, nor must any key in the listprivate com.google.common.util.concurrent.ListenableFuture<List<GetResult<V>>> multiget(List<String> keys, int ttl)
public com.google.common.util.concurrent.ListenableFuture<List<V>> getAndTouch(List<String> keys, int ttl)
BinaryMemcacheClientgetAndTouch in interface BinaryMemcacheClient<V>keys - Keys, must not be null, nor must any key in the listttl - The TTL in secondspublic com.google.common.util.concurrent.ListenableFuture<GetResult<V>> casGetAndTouch(String key, int ttl)
BinaryMemcacheClientcasGetAndTouch in interface BinaryMemcacheClient<V>key - First key, must not be nullttl - The TTL in secondspublic com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> touch(String key, int ttl)
MemcacheClienttouch in interface MemcacheClient<V>key - First key, must not be nullttl - The TTL in secondspublic com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> delete(String key)
MemcacheClientdelete in interface MemcacheClient<V>key - Key, must not be nullpublic com.google.common.util.concurrent.ListenableFuture<Long> incr(String key, long by, long initial, int ttl)
BinaryMemcacheClientincr in interface BinaryMemcacheClient<V>key - The key, must not be nullby - The value to increment the counter byinitial - The initial value if the key does not existttl - The TTL, in secondsprivate com.google.common.util.concurrent.ListenableFuture<Long> incrInternal(byte opcode, String key, long by, long initial, int ttl)
public com.google.common.util.concurrent.ListenableFuture<Long> decr(String key, long by, long initial, int ttl)
BinaryMemcacheClientdecr in interface BinaryMemcacheClient<V>key - The key, must not be nullby - The value to decrement the counter byinitial - The initial value if the key does not existttl - The TTL, in secondspublic com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> append(String key, V value)
append in interface MemcacheClient<V>public com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> append(String key, V value, long cas)
append in interface BinaryMemcacheClient<V>public com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> prepend(String key, V value)
prepend in interface MemcacheClient<V>public com.google.common.util.concurrent.ListenableFuture<MemcacheStatus> prepend(String key, V value, long cas)
prepend in interface BinaryMemcacheClient<V>public com.google.common.util.concurrent.ListenableFuture<Void> noop()
BinaryMemcacheClientnoop in interface BinaryMemcacheClient<V>public void shutdown()
MemcacheClientshutdown in interface MemcacheClient<V>public void registerForConnectionChanges(ConnectionChangeListener listener)
ObservableClientregisterForConnectionChanges in interface ObservableClientlistener - the listener to notify of connection changespublic void unregisterForConnectionChanges(ConnectionChangeListener listener)
ObservableClientunregisterForConnectionChanges in interface ObservableClientlistener - the listener to unregister.public boolean isConnected()
ObservableClientisConnected in interface ObservableClientpublic int numTotalConnections()
MemcacheClientnumTotalConnections in interface MemcacheClient<V>public int numActiveConnections()
MemcacheClientnumActiveConnections in interface MemcacheClient<V>Copyright © 2017 Spotify AB. All Rights Reserved.