V - The value type for all operationspublic class DefaultBinaryMemcacheClient<V> extends java.lang.Object implements BinaryMemcacheClient<V>
BinaryMemcacheClient| 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 |
|---|
DefaultBinaryMemcacheClient(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> |
add(java.lang.String key,
V value,
int ttl,
long cas)
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<MemcacheStatus> |
append(java.lang.String key,
V value,
long cas) |
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<GetResult<V>> |
casGetAndTouch(java.lang.String key,
int ttl)
Get the value for the provided key, including the CAS value, and sets the expiration
|
private java.util.concurrent.CompletionStage<MemcacheStatus> |
casSetInternal(OpCode opcode,
java.lang.String key,
V value,
int ttl,
long cas) |
java.util.concurrent.CompletionStage<java.lang.Long> |
decr(java.lang.String key,
long by,
long initial,
int ttl)
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
|
java.util.concurrent.CompletionStage<java.util.List<V>> |
getAndTouch(java.util.List<java.lang.String> keys,
int ttl)
Get the values for the provided keys and sets the expiration
|
java.util.concurrent.CompletionStage<V> |
getAndTouch(java.lang.String key,
int ttl)
Get the value for the provided key and sets the expiration
|
java.lang.Throwable |
getConnectionFailure()
Returns the unrecoverable connection failure, if any.
|
private java.util.concurrent.CompletionStage<GetResult<V>> |
getInternal(java.lang.String key,
int ttl) |
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,
long initial,
int ttl)
Increment a counter for the provided key
|
private java.util.concurrent.CompletionStage<java.lang.Long> |
incrInternal(OpCode opcode,
java.lang.String key,
long by,
long initial,
int ttl) |
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,
int ttl) |
java.util.concurrent.CompletionStage<java.lang.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.
|
java.util.concurrent.CompletionStage<MemcacheStatus> |
prepend(java.lang.String key,
V value) |
java.util.concurrent.CompletionStage<MemcacheStatus> |
prepend(java.lang.String key,
V value,
long cas) |
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> |
replace(java.lang.String key,
V value,
int ttl,
long cas)
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
|
private java.util.concurrent.CompletionStage<MemcacheStatus> |
setInternal(OpCode opcode,
java.lang.String key,
V value,
int 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
|
private void |
trace(OpCode opcode,
java.lang.String key,
byte[] value,
java.util.concurrent.CompletionStage<?> future) |
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 int maxKeyLength
private final java.nio.charset.Charset charset
public DefaultBinaryMemcacheClient(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> 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 secondsprivate java.util.concurrent.CompletionStage<MemcacheStatus> setInternal(OpCode opcode, java.lang.String key, V value, int ttl)
public java.util.concurrent.CompletionStage<MemcacheStatus> add(java.lang.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 java.util.concurrent.CompletionStage<MemcacheStatus> replace(java.lang.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 java.util.concurrent.CompletionStage<MemcacheStatus> casSetInternal(OpCode opcode, java.lang.String key, V value, int ttl, long cas)
public 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<V> getAndTouch(java.lang.String key, int ttl)
BinaryMemcacheClientgetAndTouch in interface BinaryMemcacheClient<V>key - The key, must not be nullttl - The TTL in secondspublic 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<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>> getInternal(java.lang.String key, int ttl)
public 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 listprivate java.util.concurrent.CompletionStage<java.util.List<GetResult<V>>> multiget(java.util.List<byte[]> keys, int ttl)
public java.util.concurrent.CompletionStage<java.util.List<V>> getAndTouch(java.util.List<java.lang.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 java.util.concurrent.CompletionStage<GetResult<V>> casGetAndTouch(java.lang.String key, int ttl)
BinaryMemcacheClientcasGetAndTouch in interface BinaryMemcacheClient<V>key - First key, must not be nullttl - The TTL in secondspublic 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.public 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<java.lang.Long> incr(java.lang.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 java.util.concurrent.CompletionStage<java.lang.Long> incrInternal(OpCode opcode, java.lang.String key, long by, long initial, int ttl)
public java.util.concurrent.CompletionStage<java.lang.Long> decr(java.lang.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 java.util.concurrent.CompletionStage<MemcacheStatus> append(java.lang.String key, V value)
append in interface MemcacheClient<V>public java.util.concurrent.CompletionStage<MemcacheStatus> append(java.lang.String key, V value, long cas)
append in interface BinaryMemcacheClient<V>public java.util.concurrent.CompletionStage<MemcacheStatus> prepend(java.lang.String key, V value)
prepend in interface MemcacheClient<V>public java.util.concurrent.CompletionStage<MemcacheStatus> prepend(java.lang.String key, V value, long cas)
prepend in interface BinaryMemcacheClient<V>public java.util.concurrent.CompletionStage<java.lang.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 java.lang.Throwable getConnectionFailure()
ObservableClientgetConnectionFailure in interface ObservableClientpublic int numTotalConnections()
ObservableClientnumTotalConnections in interface ObservableClientpublic int numActiveConnections()
ObservableClientnumActiveConnections in interface ObservableClientpublic 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.private void trace(OpCode opcode, java.lang.String key, byte[] value, java.util.concurrent.CompletionStage<?> future)
public java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2020 Spotify AB. All Rights Reserved.