|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Thread
net.spy.memcached.compat.SpyThread
net.spy.memcached.MemcachedClient
public class MemcachedClient
Client to a memcached server.
MemcachedClient c=new MemcachedClient(
new InetSocketAddress("hostname", portNum));
// Store a value (async) for one hour
c.set("someKey", 3600, someObject);
// Retrieve a value.
Object myObject=c.get("someKey");
MemcachedClient may be processing a great deal of asynchronous messages or possibly dealing with an unreachable memcached, which may delay processing. If a memcached is disabled, for example, MemcachedConnection will continue to attempt to reconnect and replay pending operations until it comes back up. To prevent this from causing your application to hang, you can use one of the asynchronous mechanisms to time out a request and cancel the operation to the server.
// Get a memcached client connected to several servers
// over the binary protocol
MemcachedClient c = new MemcachedClient(new BinaryConnectionFactory(),
AddrUtil.getAddresses("server1:11211 server2:11211"));
// Try to get a value, for up to 5 seconds, and cancel if it
// doesn't return
Object myObj = null;
Future<Object> f = c.asyncGet("someKey");
try {
myObj = f.get(5, TimeUnit.SECONDS);
// throws expecting InterruptedException, ExecutionException
// or TimeoutException
} catch (Exception e) { /* /
// Since we don't need this, go ahead and cancel the operation.
// This is not strictly necessary, but it'll save some work on
// the server. It is okay to cancel it if running.
f.cancel(true);
// Do other timeout related stuff
}
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
Thread.State, Thread.UncaughtExceptionHandler |
| Field Summary |
|---|
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Fields inherited from interface net.spy.memcached.MemcachedClientIF |
|---|
MAX_KEY_LENGTH |
| Constructor Summary | |
|---|---|
MemcachedClient(ConnectionFactory cf,
List<InetSocketAddress> addrs)
Get a memcache client over the specified memcached locations. |
|
MemcachedClient(InetSocketAddress... ia)
Get a memcache client operating on the specified memcached locations. |
|
MemcachedClient(List<InetSocketAddress> addrs)
Get a memcache client over the specified memcached locations. |
|
MemcachedClient(List<URI> baseList,
String bucketName,
String pwd)
Get a MemcachedClient based on the REST response from a Membase server. |
|
MemcachedClient(List<URI> baseList,
String bucketName,
String usr,
String pwd)
Get a MemcachedClient based on the REST response from a Membase server where the username is different than the bucket name. |
|
| Method Summary | ||
|---|---|---|
Future<Boolean> |
add(String key,
int exp,
Object o)
Add an object to the cache (using the default transcoder) iff it does not exist already. |
|
|
add(String key,
int exp,
T o,
Transcoder<T> tc)
Add an object to the cache iff it does not exist already. |
|
boolean |
addObserver(ConnectionObserver obs)
Add a connection observer. |
|
Future<Boolean> |
append(long cas,
String key,
Object val)
Append to an existing value in the cache. |
|
|
append(long cas,
String key,
T val,
Transcoder<T> tc)
Append to an existing value in the cache. |
|
|
asyncCAS(String key,
long casId,
int exp,
T value,
Transcoder<T> tc)
Asynchronous CAS operation. |
|
Future<CASResponse> |
asyncCAS(String key,
long casId,
Object value)
Asynchronous CAS operation using the default transcoder. |
|
|
asyncCAS(String key,
long casId,
T value,
Transcoder<T> tc)
Asynchronous CAS operation. |
|
Future<Long> |
asyncDecr(String key,
int by)
Asynchronous decrement. |
|
Future<Object> |
asyncGet(String key)
Get the given key asynchronously and decode with the default transcoder. |
|
|
asyncGet(String key,
Transcoder<T> tc)
Get the given key asynchronously. |
|
Future<CASValue<Object>> |
asyncGetAndLock(String key,
int exp)
Get and lock the given key asynchronously and decode with the default transcoder. |
|
|
asyncGetAndLock(String key,
int exp,
Transcoder<T> tc)
Gets and locks the given key asynchronously. |
|
Future<CASValue<Object>> |
asyncGetAndTouch(String key,
int exp)
Get the given key to reset its expiration time. |
|
|
asyncGetAndTouch(String key,
int exp,
Transcoder<T> tc)
Get the given key to reset its expiration time. |
|
BulkFuture<Map<String,Object>> |
asyncGetBulk(Collection<String> keys)
Asynchronously get a bunch of objects from the cache and decode them with the given transcoder. |
|
|
asyncGetBulk(Collection<String> keys,
Iterator<Transcoder<T>> tc_iter)
Asynchronously get a bunch of objects from the cache. |
|
|
asyncGetBulk(Collection<String> keys,
Transcoder<T> tc)
Asynchronously get a bunch of objects from the cache. |
|
BulkFuture<Map<String,Object>> |
asyncGetBulk(String... keys)
Varargs wrapper for asynchronous bulk gets with the default transcoder. |
|
|
asyncGetBulk(Transcoder<T> tc,
String... keys)
Varargs wrapper for asynchronous bulk gets. |
|
Future<CASValue<Object>> |
asyncGets(String key)
Gets (with CAS support) the given key asynchronously and decode using the default transcoder. |
|
|
asyncGets(String key,
Transcoder<T> tc)
Gets (with CAS support) the given key asynchronously. |
|
Future<Long> |
asyncIncr(String key,
int by)
Asychronous increment. |
|
|
cas(String key,
long casId,
int exp,
T value,
Transcoder<T> tc)
Perform a synchronous CAS operation. |
|
CASResponse |
cas(String key,
long casId,
Object value)
Perform a synchronous CAS operation with the default transcoder. |
|
|
cas(String key,
long casId,
T value,
Transcoder<T> tc)
Perform a synchronous CAS operation. |
|
void |
connectionEstablished(SocketAddress sa,
int reconnectCount)
A connection has just successfully been established on the given socket. |
|
void |
connectionLost(SocketAddress sa)
A connection was just lost on the given socket. |
|
long |
decr(String key,
int by)
Decrement the given key by the given value. |
|
long |
decr(String key,
int by,
long def)
Decrement the given counter, returning the new value. |
|
long |
decr(String key,
int by,
long def,
int exp)
Decrement the given counter, returning the new value. |
|
Future<Boolean> |
delete(String key)
Delete the given key from the cache. |
|
Future<Boolean> |
delete(String key,
int hold)
Deprecated. Hold values are no longer honored. |
|
Future<Boolean> |
flush()
Flush all caches from all servers immediately. |
|
Future<Boolean> |
flush(int delay)
Flush all caches from all servers with a delay of application. |
|
Object |
get(String key)
Get with a single key and decode using the default transcoder. |
|
|
get(String key,
Transcoder<T> tc)
Get with a single key. |
|
CASValue<Object> |
getAndLock(String key,
int exp)
Get and lock with a single key and decode using the default transcoder. |
|
|
getAndLock(String key,
int exp,
Transcoder<T> tc)
Getl with a single key. |
|
CASValue<Object> |
getAndTouch(String key,
int exp)
Get a single key and reset its expiration using the default transcoder. |
|
|
getAndTouch(String key,
int exp,
Transcoder<T> tc)
Get with a single key and reset its expiration. |
|
Collection<SocketAddress> |
getAvailableServers()
Get the addresses of available servers. |
|
Map<String,Object> |
getBulk(Collection<String> keys)
Get the values for multiple keys from the cache. |
|
|
getBulk(Collection<String> keys,
Transcoder<T> tc)
Get the values for multiple keys from the cache. |
|
Map<String,Object> |
getBulk(String... keys)
Get the values for multiple keys from the cache. |
|
|
getBulk(Transcoder<T> tc,
String... keys)
Get the values for multiple keys from the cache. |
|
NodeLocator |
getNodeLocator()
Get a read-only wrapper around the node locator wrapping this instance. |
|
CASValue<Object> |
gets(String key)
Gets (with CAS support) with a single key using the default transcoder. |
|
|
gets(String key,
Transcoder<T> tc)
Gets (with CAS support) with a single key. |
|
Map<SocketAddress,Map<String,String>> |
getStats()
Get all of the stats from all of the connections. |
|
Map<SocketAddress,Map<String,String>> |
getStats(String arg)
Get a set of stats from all connections. |
|
Transcoder<Object> |
getTranscoder()
Get the default transcoder that's in use. |
|
Collection<SocketAddress> |
getUnavailableServers()
Get the addresses of unavailable servers. |
|
Map<SocketAddress,String> |
getVersions()
Get the versions of all of the connected memcacheds. |
|
long |
incr(String key,
int by)
Increment the given key by the given amount. |
|
long |
incr(String key,
int by,
long def)
Increment the given counter, returning the new value. |
|
long |
incr(String key,
int by,
long def,
int exp)
Increment the given counter, returning the new value. |
|
Set<String> |
listSaslMechanisms()
Get the set of SASL mechanisms supported by the servers. |
|
Future<Boolean> |
prepend(long cas,
String key,
Object val)
Prepend to an existing value in the cache. |
|
|
prepend(long cas,
String key,
T val,
Transcoder<T> tc)
Prepend to an existing value in the cache. |
|
void |
reconfigure(Bucket bucket)
Call on a configuration update |
|
boolean |
removeObserver(ConnectionObserver obs)
Remove a connection observer. |
|
Future<Boolean> |
replace(String key,
int exp,
Object o)
Replace an object with the given value (transcoded with the default transcoder) iff there is already a value for the given key. |
|
|
replace(String key,
int exp,
T o,
Transcoder<T> tc)
Replace an object with the given value iff there is already a value for the given key. |
|
void |
run()
Infinitely loop processing IO. |
|
Future<Boolean> |
set(String key,
int exp,
Object o)
Set an object in the cache (using the default transcoder) regardless of any existing value. |
|
|
set(String key,
int exp,
T o,
Transcoder<T> tc)
Set an object in the cache regardless of any existing value. |
|
void |
shutdown()
Shut down immediately. |
|
boolean |
shutdown(long timeout,
TimeUnit unit)
Shut down this client gracefully. |
|
|
touch(String key,
int exp)
Touch the given key to reset its expiration time with the default transcoder. |
|
|
touch(String key,
int exp,
Transcoder<T> tc)
Touch the given key to reset its expiration time. |
|
boolean |
waitForQueues(long timeout,
TimeUnit unit)
Wait for the queues to die down. |
|
| Methods inherited from class net.spy.memcached.compat.SpyThread |
|---|
getLogger |
| Methods inherited from class java.lang.Thread |
|---|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public MemcachedClient(InetSocketAddress... ia)
throws IOException
ia - the memcached locations
IOException - if connections cannot be established
public MemcachedClient(List<InetSocketAddress> addrs)
throws IOException
addrs - the socket addrs
IOException - if connections cannot be established
public MemcachedClient(ConnectionFactory cf,
List<InetSocketAddress> addrs)
throws IOException
cf - the connection factory to configure connections for this clientaddrs - the socket addresses
IOException - if connections cannot be established
public MemcachedClient(List<URI> baseList,
String bucketName,
String usr,
String pwd)
throws IOException,
ConfigurationException
baseList - the URI list of one or more servers from the clusterbucketName - the bucket name in the cluster you wish to useusr - the username for the bucket; this nearly always be the same
as the bucket namepwd - the password for the bucket
IOException - if connections could not be made
ConfigurationException - if the configuration provided by the
server has issues or is not compatible
public MemcachedClient(List<URI> baseList,
String bucketName,
String pwd)
throws IOException,
ConfigurationException
baseList - the URI list of one or more servers from the clusterbucketName - the bucket name in the cluster you wish to usepwd - the password for the bucket
IOException - if connections could not be made
ConfigurationException - if the configuration provided by the
server has issues or is not compatible| Method Detail |
|---|
public void reconfigure(Bucket bucket)
Reconfigurable
reconfigure in interface Reconfigurablebucket - updated vbucket configurationpublic Collection<SocketAddress> getAvailableServers()
This is based on a snapshot in time so shouldn't be considered completely accurate, but is a useful for getting a feel for what's working and what's not working.
getAvailableServers in interface MemcachedClientIFpublic Collection<SocketAddress> getUnavailableServers()
This is based on a snapshot in time so shouldn't be considered completely accurate, but is a useful for getting a feel for what's working and what's not working.
getUnavailableServers in interface MemcachedClientIFpublic NodeLocator getNodeLocator()
getNodeLocator in interface MemcachedClientIFpublic Transcoder<Object> getTranscoder()
getTranscoder in interface MemcachedClientIF
public <T> Future<Boolean> touch(String key,
int exp)
key - the key to fetchexp - the new expiration to set for the given key
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public <T> Future<Boolean> touch(String key,
int exp,
Transcoder<T> tc)
key - the key to fetchexp - the new expiration to set for the given keytc - the transcoder to serialize and unserialize value
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public Future<Boolean> append(long cas,
String key,
Object val)
Note that the return will be false any time a mutation has not occurred.
append in interface MemcachedClientIFcas - cas identifier (ignored in the ascii protocol)key - the key to whose value will be appendedval - the value to append
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public <T> Future<Boolean> append(long cas,
String key,
T val,
Transcoder<T> tc)
Note that the return will be false any time a mutation has not occurred.
append in interface MemcachedClientIFT - cas - cas identifier (ignored in the ascii protocol)key - the key to whose value will be appendedval - the value to appendtc - the transcoder to serialize and unserialize the value
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public Future<Boolean> prepend(long cas,
String key,
Object val)
Note that the return will be false any time a mutation has not occurred.
prepend in interface MemcachedClientIFcas - cas identifier (ignored in the ascii protocol)key - the key to whose value will be prependedval - the value to append
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public <T> Future<Boolean> prepend(long cas,
String key,
T val,
Transcoder<T> tc)
Note that the return will be false any time a mutation has not occurred.
prepend in interface MemcachedClientIFT - cas - cas identifier (ignored in the ascii protocol)key - the key to whose value will be prependedval - the value to appendtc - the transcoder to serialize and unserialize the value
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public <T> Future<CASResponse> asyncCAS(String key,
long casId,
T value,
Transcoder<T> tc)
asyncCAS in interface MemcachedClientIFT - key - the keycasId - the CAS identifier (from a gets operation)value - the new valuetc - the transcoder to serialize and unserialize the value
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public <T> Future<CASResponse> asyncCAS(String key,
long casId,
int exp,
T value,
Transcoder<T> tc)
T - key - the keycasId - the CAS identifier (from a gets operation)exp - the expiration of this objectvalue - the new valuetc - the transcoder to serialize and unserialize the value
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public Future<CASResponse> asyncCAS(String key,
long casId,
Object value)
asyncCAS in interface MemcachedClientIFkey - the keycasId - the CAS identifier (from a gets operation)value - the new value
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public <T> CASResponse cas(String key,
long casId,
T value,
Transcoder<T> tc)
cas in interface MemcachedClientIFT - key - the keycasId - the CAS identifier (from a gets operation)value - the new valuetc - the transcoder to serialize and unserialize the value
OperationTimeoutException - if global operation timeout is
exceeded
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public <T> CASResponse cas(String key,
long casId,
int exp,
T value,
Transcoder<T> tc)
T - key - the keycasId - the CAS identifier (from a gets operation)exp - the expiration of this objectvalue - the new valuetc - the transcoder to serialize and unserialize the value
OperationTimeoutException - if global operation timeout is
exceeded
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public CASResponse cas(String key,
long casId,
Object value)
cas in interface MemcachedClientIFkey - the keycasId - the CAS identifier (from a gets operation)value - the new value
OperationTimeoutException - if the global operation timeout is
exceeded
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public <T> Future<Boolean> add(String key,
int exp,
T o,
Transcoder<T> tc)
The exp value is passed along to memcached exactly as
given, and will be processed per the memcached protocol specification:
Note that the return will be false any time a mutation has not occurred.
The actual value sent may either be Unix time (number of seconds since January 1, 1970, as a 32-bit value), or a number of seconds starting from current time. In the latter case, this number of seconds may not exceed 60*60*24*30 (number of seconds in 30 days); if the number sent by a client is larger than that, the server will consider it to be real Unix time value rather than an offset from current time.
add in interface MemcachedClientIFT - key - the key under which this object should be added.exp - the expiration of this objecto - the object to storetc - the transcoder to serialize and unserialize the value
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public Future<Boolean> add(String key,
int exp,
Object o)
The exp value is passed along to memcached exactly as
given, and will be processed per the memcached protocol specification:
Note that the return will be false any time a mutation has not occurred.
The actual value sent may either be Unix time (number of seconds since January 1, 1970, as a 32-bit value), or a number of seconds starting from current time. In the latter case, this number of seconds may not exceed 60*60*24*30 (number of seconds in 30 days); if the number sent by a client is larger than that, the server will consider it to be real Unix time value rather than an offset from current time.
add in interface MemcachedClientIFkey - the key under which this object should be added.exp - the expiration of this objecto - the object to store
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public <T> Future<Boolean> set(String key,
int exp,
T o,
Transcoder<T> tc)
The exp value is passed along to memcached exactly as
given, and will be processed per the memcached protocol specification:
Note that the return will be false any time a mutation has not occurred.
The actual value sent may either be Unix time (number of seconds since January 1, 1970, as a 32-bit value), or a number of seconds starting from current time. In the latter case, this number of seconds may not exceed 60*60*24*30 (number of seconds in 30 days); if the number sent by a client is larger than that, the server will consider it to be real Unix time value rather than an offset from current time.
set in interface MemcachedClientIFT - key - the key under which this object should be added.exp - the expiration of this objecto - the object to storetc - the transcoder to serialize and unserialize the value
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public Future<Boolean> set(String key,
int exp,
Object o)
The exp value is passed along to memcached exactly as
given, and will be processed per the memcached protocol specification:
Note that the return will be false any time a mutation has not occurred.
The actual value sent may either be Unix time (number of seconds since January 1, 1970, as a 32-bit value), or a number of seconds starting from current time. In the latter case, this number of seconds may not exceed 60*60*24*30 (number of seconds in 30 days); if the number sent by a client is larger than that, the server will consider it to be real Unix time value rather than an offset from current time.
set in interface MemcachedClientIFkey - the key under which this object should be added.exp - the expiration of this objecto - the object to store
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public <T> Future<Boolean> replace(String key,
int exp,
T o,
Transcoder<T> tc)
The exp value is passed along to memcached exactly as
given, and will be processed per the memcached protocol specification:
Note that the return will be false any time a mutation has not occurred.
The actual value sent may either be Unix time (number of seconds since January 1, 1970, as a 32-bit value), or a number of seconds starting from current time. In the latter case, this number of seconds may not exceed 60*60*24*30 (number of seconds in 30 days); if the number sent by a client is larger than that, the server will consider it to be real Unix time value rather than an offset from current time.
replace in interface MemcachedClientIFT - key - the key under which this object should be added.exp - the expiration of this objecto - the object to storetc - the transcoder to serialize and unserialize the value
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public Future<Boolean> replace(String key,
int exp,
Object o)
The exp value is passed along to memcached exactly as
given, and will be processed per the memcached protocol specification:
Note that the return will be false any time a mutation has not occurred.
The actual value sent may either be Unix time (number of seconds since January 1, 1970, as a 32-bit value), or a number of seconds starting from current time. In the latter case, this number of seconds may not exceed 60*60*24*30 (number of seconds in 30 days); if the number sent by a client is larger than that, the server will consider it to be real Unix time value rather than an offset from current time.
replace in interface MemcachedClientIFkey - the key under which this object should be added.exp - the expiration of this objecto - the object to store
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public <T> Future<T> asyncGet(String key,
Transcoder<T> tc)
asyncGet in interface MemcachedClientIFT - key - the key to fetchtc - the transcoder to serialize and unserialize value
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requestspublic Future<Object> asyncGet(String key)
asyncGet in interface MemcachedClientIFkey - the key to fetch
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public <T> Future<CASValue<T>> asyncGets(String key,
Transcoder<T> tc)
asyncGets in interface MemcachedClientIFT - key - the key to fetchtc - the transcoder to serialize and unserialize value
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requestspublic Future<CASValue<Object>> asyncGets(String key)
asyncGets in interface MemcachedClientIFkey - the key to fetch
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public <T> CASValue<T> gets(String key,
Transcoder<T> tc)
gets in interface MemcachedClientIFT - key - the key to gettc - the transcoder to serialize and unserialize value
OperationTimeoutException - if global operation timeout is
exceeded
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public <T> CASValue<T> getAndTouch(String key,
int exp,
Transcoder<T> tc)
T - key - the key to getexp - the new expiration for the keytc - the transcoder to serialize and unserialize value
OperationTimeoutException - if the global operation timeout is
exceeded
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public CASValue<Object> getAndTouch(String key,
int exp)
key - the key to getexp - the new expiration for the key
OperationTimeoutException - if the global operation timeout is
exceeded
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requestspublic CASValue<Object> gets(String key)
gets in interface MemcachedClientIFkey - the key to get
OperationTimeoutException - if the global operation timeout is
exceeded
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public <T> T get(String key,
Transcoder<T> tc)
get in interface MemcachedClientIFT - key - the key to gettc - the transcoder to serialize and unserialize value
OperationTimeoutException - if the global operation timeout is
exceeded
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requestspublic Object get(String key)
get in interface MemcachedClientIFkey - the key to get
OperationTimeoutException - if the global operation timeout is
exceeded
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public <T> Future<CASValue<T>> asyncGetAndLock(String key,
int exp,
Transcoder<T> tc)
key - the key to fetch and lockexp - the amount of time the lock should be valid for in seconds.tc - the transcoder to serialize and unserialize value
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public Future<CASValue<Object>> asyncGetAndLock(String key,
int exp)
key - the key to fetch and lockexp - the amount of time the lock should be valid for in seconds.
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public <T> BulkFuture<Map<String,T>> asyncGetBulk(Collection<String> keys,
Iterator<Transcoder<T>> tc_iter)
asyncGetBulk in interface MemcachedClientIFT - keys - the keys to requesttc_iter - an iterator of transcoders to serialize and
unserialize values; the transcoders are matched with
the keys in the same order. The minimum of the key
collection length and number of transcoders is used
and no exception is thrown if they do not match
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public <T> BulkFuture<Map<String,T>> asyncGetBulk(Collection<String> keys,
Transcoder<T> tc)
asyncGetBulk in interface MemcachedClientIFT - keys - the keys to requesttc - the transcoder to serialize and unserialize values
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requestspublic BulkFuture<Map<String,Object>> asyncGetBulk(Collection<String> keys)
asyncGetBulk in interface MemcachedClientIFkeys - the keys to request
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public <T> BulkFuture<Map<String,T>> asyncGetBulk(Transcoder<T> tc,
String... keys)
asyncGetBulk in interface MemcachedClientIFT - tc - the transcoder to serialize and unserialize valuekeys - one more more keys to get
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requestspublic BulkFuture<Map<String,Object>> asyncGetBulk(String... keys)
asyncGetBulk in interface MemcachedClientIFkeys - one more more keys to get
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public Future<CASValue<Object>> asyncGetAndTouch(String key,
int exp)
key - the key to fetchexp - the new expiration to set for the given key
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public <T> Future<CASValue<T>> asyncGetAndTouch(String key,
int exp,
Transcoder<T> tc)
key - the key to fetchexp - the new expiration to set for the given keytc - the transcoder to serialize and unserialize value
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public <T> Map<String,T> getBulk(Collection<String> keys,
Transcoder<T> tc)
getBulk in interface MemcachedClientIFT - keys - the keystc - the transcoder to serialize and unserialize value
OperationTimeoutException - if the global operation timeout is
exceeded
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requestspublic Map<String,Object> getBulk(Collection<String> keys)
getBulk in interface MemcachedClientIFkeys - the keys
OperationTimeoutException - if the global operation timeout is
exceeded
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public <T> Map<String,T> getBulk(Transcoder<T> tc,
String... keys)
getBulk in interface MemcachedClientIFT - tc - the transcoder to serialize and unserialize valuekeys - the keys
OperationTimeoutException - if the global operation timeout is
exceeded
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requestspublic Map<String,Object> getBulk(String... keys)
getBulk in interface MemcachedClientIFkeys - the keys
OperationTimeoutException - if the global operation timeout is
exceeded
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requestspublic Map<SocketAddress,String> getVersions()
getVersions in interface MemcachedClientIFIllegalStateException - in the rare circumstance where queue
is too full to accept any more requestspublic Map<SocketAddress,Map<String,String>> getStats()
getStats in interface MemcachedClientIFIllegalStateException - in the rare circumstance where queue
is too full to accept any more requestspublic Map<SocketAddress,Map<String,String>> getStats(String arg)
getStats in interface MemcachedClientIFarg - which stats to get
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public <T> CASValue<T> getAndLock(String key,
int exp,
Transcoder<T> tc)
key - the key to get and lockexp - the amount of time the lock should be valid for in seconds.tc - the transcoder to serialize and unserialize value
OperationTimeoutException - if the global operation timeout is
exceeded
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public CASValue<Object> getAndLock(String key,
int exp)
key - the key to get and lockexp - the amount of time the lock should be valid for in seconds.
OperationTimeoutException - if the global operation timeout is
exceeded
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public long incr(String key,
int by)
incr in interface MemcachedClientIFkey - the keyby - the amount to increment
OperationTimeoutException - if the global operation timeout is
exceeded
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public long decr(String key,
int by)
decr in interface MemcachedClientIFkey - the keyby - the value
OperationTimeoutException - if the global operation timeout is
exceeded
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public long incr(String key,
int by,
long def,
int exp)
incr in interface MemcachedClientIFkey - the keyby - the amount to incrementdef - the default value (if the counter does not exist)exp - the expiration of this object
OperationTimeoutException - if the global operation timeout is
exceeded
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public long decr(String key,
int by,
long def,
int exp)
decr in interface MemcachedClientIFkey - the keyby - the amount to decrementdef - the default value (if the counter does not exist)exp - the expiration of this object
OperationTimeoutException - if the global operation timeout is
exceeded
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public Future<Long> asyncIncr(String key,
int by)
asyncIncr in interface MemcachedClientIFkey - key to incrementby - the amount to increment the value by
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public Future<Long> asyncDecr(String key,
int by)
asyncDecr in interface MemcachedClientIFkey - key to incrementby - the amount to increment the value by
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public long incr(String key,
int by,
long def)
incr in interface MemcachedClientIFkey - the keyby - the amount to incrementdef - the default value (if the counter does not exist)
OperationTimeoutException - if the global operation timeout is
exceeded
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
public long decr(String key,
int by,
long def)
decr in interface MemcachedClientIFkey - the keyby - the amount to decrementdef - the default value (if the counter does not exist)
OperationTimeoutException - if the global operation timeout is
exceeded
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requests
@Deprecated
public Future<Boolean> delete(String key,
int hold)
The hold argument specifies the amount of time in seconds (or Unix time until which) the client wishes the server to refuse "add" and "replace" commands with this key. For this amount of item, the item is put into a delete queue, which means that it won't possible to retrieve it by the "get" command, but "add" and "replace" command with this key will also fail (the "set" command will succeed, however). After the time passes, the item is finally deleted from server memory.
key - the key to deletehold - how long the key should be unavailable to add commands
public Future<Boolean> delete(String key)
delete in interface MemcachedClientIFkey - the key to delete
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requestspublic Future<Boolean> flush(int delay)
flush in interface MemcachedClientIFdelay - the period of time to delay, in seconds
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requestspublic Future<Boolean> flush()
flush in interface MemcachedClientIFIllegalStateException - in the rare circumstance where queue
is too full to accept any more requestspublic Set<String> listSaslMechanisms()
MemcachedClientIF
listSaslMechanisms in interface MemcachedClientIFpublic void run()
run in interface Runnablerun in class Threadpublic void shutdown()
shutdown in interface MemcachedClientIF
public boolean shutdown(long timeout,
TimeUnit unit)
shutdown in interface MemcachedClientIFtimeout - the amount of time time for shutdownunit - the TimeUnit for the timeout
public boolean waitForQueues(long timeout,
TimeUnit unit)
waitForQueues in interface MemcachedClientIFtimeout - the amount of time time for shutdownunit - the TimeUnit for the timeout
IllegalStateException - in the rare circumstance where queue
is too full to accept any more requestspublic boolean addObserver(ConnectionObserver obs)
addObserver in interface MemcachedClientIFobs - the ConnectionObserver you wish to add
public boolean removeObserver(ConnectionObserver obs)
removeObserver in interface MemcachedClientIFobs - the ConnectionObserver you wish to add
public void connectionEstablished(SocketAddress sa,
int reconnectCount)
ConnectionObserver
connectionEstablished in interface ConnectionObserversa - the address of the node whose connection was establishedreconnectCount - the number of attempts before the connection was
establishedpublic void connectionLost(SocketAddress sa)
ConnectionObserver
connectionLost in interface ConnectionObserversa - the address of the node whose connection was lost
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||