V - The value type for all operationspublic class DefaultAsciiMemcacheClient<V> extends java.lang.Object implements AsciiMemcacheClient<V>
AsciiMemcacheClient| Modifier and Type | Field and Description |
|---|---|
private java.nio.charset.Charset |
charset |
private int |
maxKeyLength |
private Metrics |
metrics |
private RawMemcacheClient |
rawMemcacheClient |
private Tracer |
tracer |
private TransformerUtil<V> |
transformerUtil |
private Transcoder<V> |
valueTranscoder |
| Constructor and Description |
|---|
DefaultAsciiMemcacheClient(RawMemcacheClient rawMemcacheClient,
Metrics metrics,
Tracer tracer,
Transcoder<V> valueTranscoder,
java.nio.charset.Charset charset,
int maxKeyLength) |
| Modifier and Type | Method and Description |
|---|---|
java.util.concurrent.CompletionStage<MemcacheStatus> |
add(java.lang.String key,
V value,
int ttl)
Add a key in memcache with the provided value, with the specified TTL.
|
java.util.concurrent.CompletionStage<MemcacheStatus> |
append(java.lang.String key,
V value) |
java.util.concurrent.CompletionStage<java.util.List<GetResult<V>>> |
casGet(java.util.List<java.lang.String> keys)
Get the value for the provided keys
|
java.util.concurrent.CompletionStage<GetResult<V>> |
casGet(java.lang.String key)
Get the value for the provided key, including the CAS value
|
java.util.concurrent.CompletionStage<java.lang.Long> |
decr(java.lang.String key,
long by)
Decrement a counter for the provided key
|
java.util.concurrent.CompletionStage<MemcacheStatus> |
delete(java.lang.String key)
Delete the provided key
|
java.util.concurrent.CompletionStage<MemcacheStatus> |
delete(java.lang.String key,
long cas)
Deletes a key with CAS check.
|
java.util.concurrent.CompletionStage<MemcacheStatus> |
deleteAll(java.lang.String key)
Delete the provided key on all memcached instances.
|
java.util.concurrent.CompletionStage<MemcacheStatus> |
flushAll(int delay)
Flushes all entries in the storage
|
java.util.concurrent.CompletionStage<java.util.List<V>> |
get(java.util.List<java.lang.String> keys)
Get the value for the provided keys
|
java.util.concurrent.CompletionStage<V> |
get(java.lang.String key)
Get the value for the provided key
|
private java.util.concurrent.CompletionStage<GetResult<V>> |
get(java.lang.String key,
boolean withCas) |
java.lang.Throwable |
getConnectionFailure()
Returns the unrecoverable connection failure, if any.
|
RawMemcacheClient |
getRawMemcacheClient()
Note: This is typically only useful for testing and debugging
|
java.util.concurrent.CompletionStage<java.util.Map<java.lang.String,MemcachedStats>> |
getStats(java.lang.String key)
Get raw statistics from the memcached instances.
|
java.util.concurrent.CompletionStage<java.lang.Long> |
incr(java.lang.String key,
long by)
Increment a counter for the provided key
|
boolean |
isConnected()
Is the client connected to a server?
|
private java.util.concurrent.CompletionStage<java.util.List<GetResult<V>>> |
multiget(java.util.List<byte[]> keys,
boolean withCas) |
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.
|
java.util.concurrent.CompletionStage<MemcacheStatus> |
prepend(java.lang.String key,
V value) |
void |
registerForConnectionChanges(ConnectionChangeListener listener)
Register for connection change events.
|
java.util.concurrent.CompletionStage<MemcacheStatus> |
replace(java.lang.String key,
V value,
int ttl)
Replace a key in memcache with the provided value, with the specified TTL.
|
java.util.concurrent.CompletionStage<MemcacheStatus> |
set(java.lang.String key,
V value,
int ttl)
Set a key in memcache to the provided value, with the specified TTL
|
java.util.concurrent.CompletionStage<MemcacheStatus> |
set(java.lang.String key,
V value,
int ttl,
long cas)
Compare and set a key in memcache to the provided value, with the specified TTL
|
void |
shutdown()
Shut down the client.
|
java.lang.String |
toString() |
java.util.concurrent.CompletionStage<MemcacheStatus> |
touch(java.lang.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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitawaitConnected, awaitDisconnected, awaitFullyConnected, awaitFullyDisconnected, awaitFuture, connectFuture, disconnectFuture, fullyConnectedFuture, fullyDisconnectFutureprivate final RawMemcacheClient rawMemcacheClient
private final Metrics metrics
private final Tracer tracer
private final Transcoder<V> valueTranscoder
private final TransformerUtil<V> transformerUtil
private final java.nio.charset.Charset charset
private final int maxKeyLength
public DefaultAsciiMemcacheClient(RawMemcacheClient rawMemcacheClient, Metrics metrics, Tracer tracer, Transcoder<V> valueTranscoder, java.nio.charset.Charset charset, int maxKeyLength)
public java.util.concurrent.CompletionStage<MemcacheStatus> set(java.lang.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 java.util.concurrent.CompletionStage<MemcacheStatus> set(java.lang.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 java.util.concurrent.CompletionStage<MemcacheStatus> delete(java.lang.String key)
MemcacheClientdelete in interface MemcacheClient<V>key - Key, must not be nullpublic java.util.concurrent.CompletionStage<MemcacheStatus> delete(java.lang.String key, long cas)
MemcacheClientdelete in interface MemcacheClient<V>key - The key, must not be nullcas - The CAS value, must match the value on the server for the set to go throughpublic java.util.concurrent.CompletionStage<MemcacheStatus> deleteAll(java.lang.String key)
MemcacheClientdeleteAll in interface MemcacheClient<V>key - Key, must not be nullpublic java.util.concurrent.CompletionStage<MemcacheStatus> add(java.lang.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 java.util.concurrent.CompletionStage<MemcacheStatus> replace(java.lang.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 secondspublic java.util.concurrent.CompletionStage<MemcacheStatus> append(java.lang.String key, V value)
append in interface MemcacheClient<V>public java.util.concurrent.CompletionStage<MemcacheStatus> prepend(java.lang.String key, V value)
prepend in interface MemcacheClient<V>public java.util.concurrent.CompletionStage<java.lang.Long> incr(java.lang.String key,
long by)
AsciiMemcacheClientincr in interface AsciiMemcacheClient<V>key - The key, must not be nullby - The value to increment the counter bypublic java.util.concurrent.CompletionStage<java.lang.Long> decr(java.lang.String key,
long by)
AsciiMemcacheClientdecr in interface AsciiMemcacheClient<V>key - The key, must not be nullby - The value to decrement the counter bypublic java.util.concurrent.CompletionStage<V> get(java.lang.String key)
MemcacheClientget in interface MemcacheClient<V>key - The key, must not be nullpublic java.util.concurrent.CompletionStage<GetResult<V>> casGet(java.lang.String key)
MemcacheClientcasGet in interface MemcacheClient<V>key - First key, must not be nullprivate java.util.concurrent.CompletionStage<GetResult<V>> get(java.lang.String key, boolean withCas)
public java.util.concurrent.CompletionStage<java.util.List<V>> get(java.util.List<java.lang.String> keys)
MemcacheClientget in interface MemcacheClient<V>keys - Keys, must not be null, nor must any key in the listpublic java.util.concurrent.CompletionStage<java.util.List<GetResult<V>>> casGet(java.util.List<java.lang.String> keys)
MemcacheClientcasGet in interface MemcacheClient<V>keys - Keys, must not be null, nor must any key in the listpublic java.util.concurrent.CompletionStage<MemcacheStatus> touch(java.lang.String key, int ttl)
MemcacheClienttouch in interface MemcacheClient<V>key - First key, must not be nullttl - The TTL in secondspublic java.util.concurrent.CompletionStage<MemcacheStatus> flushAll(int delay)
MemcacheClientflushAll in interface MemcacheClient<V>delay - The flush delay in seconds.private java.util.concurrent.CompletionStage<java.util.List<GetResult<V>>> multiget(java.util.List<byte[]> keys, boolean withCas)
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 java.lang.Throwable getConnectionFailure()
ObservableClientgetConnectionFailure in interface ObservableClientpublic int numTotalConnections()
ObservableClientnumTotalConnections in interface ObservableClientpublic int numActiveConnections()
ObservableClientnumActiveConnections in interface ObservableClientpublic java.lang.String toString()
toString in class java.lang.Objectpublic RawMemcacheClient getRawMemcacheClient()
MemcacheClientgetRawMemcacheClient in interface MemcacheClient<V>public java.util.concurrent.CompletionStage<java.util.Map<java.lang.String,MemcachedStats>> getStats(java.lang.String key)
MemcacheClientThe reason for including potentially multiple statistics containers is to support the ketama use-case where there may be multiple memcached instances.
If any of the instances fail to return statistics, the exception will be propagated.
Valid keys are:
getStats in interface MemcacheClient<V>key - - statistics key.Copyright © 2020 Spotify AB. All Rights Reserved.