Class XMemcachedClient
java.lang.Object
net.rubyeye.xmemcached.XMemcachedClient
- All Implemented Interfaces:
MemcachedClient, XMemcachedClientMBean
- Direct Known Subclasses:
AWSElasticCacheClient
Memcached Client for connecting to memcached server and do operations.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Map<InetSocketAddress, AuthInfo> protected CommandFactoryprotected intprotected MemcachedConnectorprivate longprivate static final Stringprivate booleanprivate booleanprivate KeyProviderprivate static final org.slf4j.Loggerprotected intprivate MemcachedHandlerprivate Stringstatic final ThreadLocal<String> namespace thread local.protected longprotected booleanprivate booleanprotected final AtomicIntegerprotected MemcachedSessionComparatorprotected MemcachedSessionLocatorprivate booleanprivate Threadprivate final CopyOnWriteArrayList<MemcachedClientStateListenerAdapter> private intprivate TranscoderFields inherited from interface MemcachedClient
DEFAULT_CONNECT_TIMEOUT, DEFAULT_CONNECTION_POOL_SIZE, DEFAULT_HEAL_SESSION_INTERVAL, DEFAULT_MAX_QUEUED_NOPS, DEFAULT_MAX_TIMEOUTEXCEPTION_THRESHOLD, DEFAULT_OP_TIMEOUT, DEFAULT_READ_THREAD_COUNT, DEFAULT_SESSION_IDLE_TIMEOUT, DEFAULT_SESSION_READ_BUFF_SIZE, DEFAULT_TCP_KEEPLIVE, DEFAULT_TCP_NO_DELAY, DEFAULT_TCP_RECV_BUFF_SIZE, DEFAULT_TCP_SEND_BUFF_SIZE, DYNAMIC_MAX_QUEUED_NOPS, MAX_QUEUED_NOPS -
Constructor Summary
ConstructorsConstructorDescriptionXMemcachedClient(String server, int port) XMemcached constructor,default weight is 1XMemcachedClient(String host, int port, int weight) XMemcached constructorXMemcachedClient(InetSocketAddress inetSocketAddress) XMemcachedClient(InetSocketAddress inetSocketAddress, int weight) XMemcachedClient(InetSocketAddress inetSocketAddress, int weight, CommandFactory cmdFactory) XMemcached Constructor.XMemcachedClient(List<InetSocketAddress> addressList) XMemcached Constructor.Every server's weight is one by default.XMemcachedClient(List<InetSocketAddress> addressList, CommandFactory cmdFactory) XMemcached Constructor.Every server's weight is one by default.XMemcachedClient(MemcachedSessionLocator locator, MemcachedSessionComparator comparator, BufferAllocator allocator, Configuration conf, Map<SocketOption, Object> socketOptions, CommandFactory commandFactory, Transcoder transcoder, Map<InetSocketAddress, InetSocketAddress> addressMap, int[] weights, List<MemcachedClientStateListener> stateListeners, Map<InetSocketAddress, AuthInfo> infoMap, int poolSize, long connectTimeout, String name, boolean failureMode, boolean resolveInetAddresses) XMemcachedClient constructor.XMemcachedClient(MemcachedSessionLocator locator, MemcachedSessionComparator comparator, BufferAllocator allocator, Configuration conf, Map<SocketOption, Object> socketOptions, CommandFactory commandFactory, Transcoder transcoder, Map<InetSocketAddress, InetSocketAddress> addressMap, List<MemcachedClientStateListener> stateListeners, Map<InetSocketAddress, AuthInfo> map, int poolSize, long connectTimeout, String name, boolean failureMode, boolean resolveInetAddresses) XMemcachedClient constructor.Every server's weight is one by default. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanfinal booleanfinal <T> booleanadd(String key, int exp, T value, Transcoder<T> transcoder) final <T> booleanadd(String key, int exp, T value, Transcoder<T> transcoder, long timeout) Add key-value item to memcached, success only when the key is not exists in memcached.private <T> booleanadd0(String key, int exp, T value, Transcoder<T> transcoder, long timeout) voidaddOneServerWithWeight(String server, int weight) Add a memcached serverfinal voidAdd memcached serversfinal voidAadd a memcached server,the thread call this method will be blocked until the connecting operations completed(success or fail)final voidadd a memcached server to MemcachedClientfinal voidaddServer(InetSocketAddress inetSocketAddress) Add a memcached server,the thread call this method will be blocked until the connecting operations completed(success or fail)final voidaddServer(InetSocketAddress inetSocketAddress, int weight) voidaddStateListener(MemcachedClientStateListener listener) Add a memcached client listenervoidaddWithNoReply(String key, int exp, Object value) Add key-value item to memcached, success only when the key is not exists in memcached.This method doesn't wait for reply.<T> voidaddWithNoReply(String key, int exp, T value, Transcoder<T> transcoder) final booleanfinal booleanAppend value to key's data item,this method will wait for replyvoidappendWithNoReply(String key, Object value) Append value to key's data item,this method doesn't wait for reply.voidset current namespace for following operations with memcached client.It must be ended withMemcachedClient.endWithNamespace()method.For example:private voidbuildConnector(MemcachedSessionLocator locator, MemcachedSessionComparator comparator, BufferAllocator bufferAllocator, Configuration configuration, Map<SocketOption, Object> socketOptions, CommandFactory commandFactory, Transcoder transcoder) final booleanfinal booleanfinal <T> booleancas(String key, int exp, CASOperation<T> operation) final <T> booleancas(String key, int exp, CASOperation<T> operation, Transcoder<T> transcoder) Cas is a check and set operation which means "store this data but only if no one else has updated since I last fetched it."final <T> booleancas(String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation) final <T> booleancas(String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation, Transcoder<T> transcoder) cas is a check and set operation which means "store this data but only if no one else has updated since I last fetched it."final <T> booleancas(String key, int exp, T value, Transcoder<T> transcoder, long cas) final <T> booleancas(String key, int exp, T value, Transcoder<T> transcoder, long timeout, long cas) Cas is a check and set operation which means "store this data but only if no one else has updated since I last fetched it."final <T> booleancas(String key, CASOperation<T> operation) final <T> booleancas(String key, GetsResponse<T> getsReponse, CASOperation<T> operation) private final <T> booleancas0(String key, int exp, GetsResponse<T> getsResponse, CASOperation<T> operation, Transcoder<T> transcoder, byte[] keyBytes, boolean noreply) <T> voidcasWithNoReply(String key, int exp, CASOperation<T> operation) <T> voidcasWithNoReply(String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation) cas noreply<T> voidcasWithNoReply(String key, CASOperation<T> operation) <T> voidcasWithNoReply(String key, GetsResponse<T> getsResponse, CASOperation<T> operation) private final Collection<List<String>> catalogKeys(Collection<String> keyCollections) Hash key to serversprotected voidcheckException(Command command) private voidcheckServerPort(String server, int port) private final <T> byte[]checkStoreArguments(String key, int exp, T value) protected voidconnect(InetSocketAddressWrapper inetSocketAddressWrapper) private Stringfinal long"decr" are used to change data for some item in-place, decrementing it.longlong"decr" are used to change data for some item in-place, decrementing it.long"incr" are used to change data for some item in-place, incrementing it.final voiddecrWithNoReply(String key, long delta) "decr" are used to change data for some item in-place, decrementing it.final booleanfinal booleanDelete key's data item from memcached.It it is not exists,return false. time is 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.booleanDelete key's date item from memcachedbooleanDelete key's date item from memcached only if its cas value is the same as what was read.private booleanfinal voiddeleteWithNoReply(String key) final voiddeleteWithNoReply(String key, int time) Delete key's data item from memcached.This method doesn't wait for replyvoidRemove current namespace set for this memcached client.It must begin withMemcachedClient.beginWithNamespace(String)method.private final <T> Objectfetch0(String key, byte[] keyBytes, CommandType cmdType, long timeout, Transcoder<T> transcoder) final voidflushAll()Make All connected memcached's data item invalidfinal voidflushAll(int exptime, long timeout) final voidflushAll(long timeout) Make All connected memcached's data item invalidfinal voidThis method is deprecated,please use flushAll(InetSocketAddress) instead.final voidflushAll(InetSocketAddress address) Invalidate all existing items immediatelyfinal voidflushAll(InetSocketAddress address, long timeout) final voidflushAll(InetSocketAddress address, long timeout, int exptime) private voidflushAllMemcachedServers(long timeout, boolean noreply, int exptime) voidvoidflushAllWithNoReply(int exptime) voidflushAllWithNoReply(InetSocketAddress address) voidflushAllWithNoReply(InetSocketAddress address, int exptime) private voidflushSpecialMemcachedServer(InetSocketAddress address, long timeout, boolean noreply, int exptime) final <T> Tfinal <T> Tfinal <T> Tget(String key, long timeout, Transcoder<T> transcoder) Get value by keyfinal <T> Tget(String key, Transcoder<T> transcoder) get(Collection<String> keyCollections) get(Collection<String> keyCollections, long timeout) get(Collection<String> keyCollections, long timeout, Transcoder<T> transcoder) Bulk get itemsget(Collection<String> keyCollections, Transcoder<T> transcoder) private <T> Objectget0(String key, long timeout, CommandType cmdType, Transcoder<T> transcoder) <T> TgetAndTouch(String key, int newExp) Get item and set a new expiration time for it,using default opTimeout<T> TgetAndTouch(String key, int newExp, long opTimeout) Get item and set a new expiration time for itreturn current all auth infoRetruns the AuthInfo for all server strings (hostname:port)Returns available memcached servers list.final Collection<InetSocketAddress> Deprecated.final CommandFactoryfinal intfinal Connectorreturn the session managerlongGet the connect timeoutprivate AtomicIntegergetContinuousTimeoutCounter(Session session) getCounter(String key) Get counter for key,and if the key's value is not set,then set it with 0.getCounter(String key, long initialValue) Get counter for key,and if the key's value is not set,then set it with initial value.longReturn the default heal session interval in millisecondsgetKeyIterator(InetSocketAddress address) Deprecated.memcached 1.6.x will remove cachedump stats command,so this method will be removed in the futuregetMulti0(Collection<String> keys, long timeout, CommandType cmdType, Transcoder<T> transcoder) getName()Return the cache instance namegetNamespace(String ns) Returns the real namespace of ns.private Stringfinal longget operation timeout settingReturns reconnecting task queue,the queue is thread-safe and 'weakly consistent',but maybe you should not modify it at all.final <T> GetsResponse<T> final <T> GetsResponse<T> final <T> GetsResponse<T> gets(String key, long timeout, Transcoder<T> transcoder) Just like get,But it return a GetsResponse,include cas value for cas update.final <T> GetsResponse<T> gets(String key, Transcoder transcoder) final <T> Map<String, GetsResponse<T>> gets(Collection<String> keyCollections) final <T> Map<String, GetsResponse<T>> gets(Collection<String> keyCollections, long timeout) final <T> Map<String, GetsResponse<T>> gets(Collection<String> keyCollections, long timeout, Transcoder<T> transcoder) Bulk gets itemsfinal <T> Map<String, GetsResponse<T>> gets(Collection<String> keyCollections, Transcoder<T> transcoder) private final <T> GetsResponse<T> gets0(String key, byte[] keyBytes, Transcoder<T> transcoder) Get all connected memcached serversfinal MemcachedSessionLocatorGet all current state listenersfinal Map<InetSocketAddress, Map<String, String>> getStats()getStats(long timeout) Get stats from all memcached serversfinal Map<InetSocketAddress, Map<String, String>> getStatsByItem(String itemName) Get special item stats.final Map<InetSocketAddress, Map<String, String>> getStatsByItem(String itemName, long timeout) intReturns maximum number of timeout exception for closing connection.final Transcoderreturn default transcoder,default is SerializingTranscoderfinal Map<InetSocketAddress, String> Get all connected memcached servers's version.final Map<InetSocketAddress, String> getVersions(long timeout) final long"incr" are used to change data for some item in-place, incrementing it.longlong"incr" are used to change data for some item in-place, incrementing it.long"incr" are used to change data for some item in-place, incrementing it.final voidincrWithNoReply(String key, long delta) "incr" are used to change data for some item in-place, incrementing it.voidInvalidate all namespace under the namespace using the default operation timeout.voidinvalidateNamespace(String ns, long opTimeout) Invalidate all items under the namespace.booleanReturns if client is in failure mode.booleanfinal booleanprivate final booleanprotected voidprotected MemcachedConnectornewConnector(BufferAllocator bufferAllocator, Configuration configuration, MemcachedSessionLocator memcachedSessionLocator, MemcachedSessionComparator memcachedSessionComparator, CommandFactory commandFactory, int poolSize, int maxQueuedNoReplyOperations) protected InetSocketAddressnewSocketAddress(String server, int port) private final voidoptimiezeSetReadThreadCount(Configuration conf, int addressCount) final booleanfinal booleanPrepend value to key's data item in memcached.This method doesn't wait for reply.voidprependWithNoReply(String key, Object value) Prepend value to key's data item in memcached.This method doesn't wait for reply.private StringpreProcessKey(String key) reduceResult(CommandType cmdType, Transcoder<T> transcoder, List<Command> commands) private final voidfinal voidremoveServer(String hostList) Remove memcached serversvoidremoveServer(InetSocketAddress address) Remove memcached server with the exact given address.voidRemove a memcached client listenerfinal booleanfinal booleanfinal <T> booleanreplace(String key, int exp, T value, Transcoder<T> transcoder) final <T> booleanreplace(String key, int exp, T value, Transcoder<T> transcoder, long timeout) Replace the key's data item in memcached,success only when the key's data item is exists in memcached.This method will wait for reply from server.voidreplaceWithNoReply(String key, int exp, Object value) Replace the key's data item in memcached,success only when the key's data item is exists in memcached.This method doesn't wait for reply from server.<T> voidreplaceWithNoReply(String key, int exp, T value, Transcoder<T> transcoder) protected final SessionsendCommand(Command cmd) private final <T> CommandsendGetMultiCommand(Collection<String> keys, CountDownLatch latch, CommandType cmdType, Transcoder<T> transcoder) private longsendIncrOrDecrCommand(String key, long delta, long initValue, CommandType cmdType, boolean noreply, long operationTimeout, int exp) private final <T> booleansendStoreCommand(Command command, long timeout) final booleanfinal booleanfinal <T> booleanset(String key, int exp, T value, Transcoder<T> transcoder) final <T> booleanset(String key, int exp, T value, Transcoder<T> transcoder, long timeout) Store key-value item to memcachedvoidConfigure auth infofinal voidsetBufferAllocator(BufferAllocator bufferAllocator) Set the nio's ByteBuffer Allocator,use SimpleBufferAllocator by default.voidsetConnectionPoolSize(int poolSize) In a high concurrent enviroment,you may want to pool memcached clients.But a xmemcached client has to start a reactor thread and some thread pools,if you create too many clients,the cost is very large.voidsetConnectTimeout(long connectTimeout) Set the connect timeout,default is 1 minutesvoidsetEnableHealSession(boolean enableHealSession) If the memcached dump or network error cause connection closed,xmemcached would try to heal the connection.You can disable this behaviour by using this method:
client.setEnableHealSession(false);
The default value is true.voidsetEnableHeartBeat(boolean enableHeartBeat) Whether to enable heart beatvoidsetFailureMode(boolean failureMode) Configure wheather to set client in failure mode.If set it to true,that means you want to configure client in failure mode.voidsetHealSessionInterval(long healConnectionInterval) If the memcached dump or network error cause connection closed,xmemcached would try to heal the connection.The interval between reconnections is 2 seconds by default.voidsetKeyProvider(KeyProvider keyProvider) Set a key provider for pre-processing keys before sending them to memcached.voidsetLoggingLevelVerbosity(InetSocketAddress address, int level) Set the verbosity level of the memcached's logging output.This method will wait for reply.voidsetLoggingLevelVerbosityWithNoReply(InetSocketAddress address, int level) Set the verbosity level of the memcached's logging output.This method doesn't wait for reply from server(package private) voidsetMaxQueuedNoReplyOperations(int maxQueuedNoReplyOperations) Set max queued noreply operations numberprivate voidsetMemcachedLoggingLevel(InetSocketAddress address, int level, boolean noreply) final voidsetMergeFactor(int mergeFactor) Set the merge factor,this factor determins how many 'get' commands would be merge to one multi-get command.default is 150voidSet cache instance namefinal voidsetOpTimeout(long opTimeout) set operation timeout,default is one second.voidsetOptimizeGet(boolean optimizeGet) Enable/Disable merge many get commands to one multi-get command.true is to enable it,false is to disable it.Default is true.Recommend users to enable it.final voidsetOptimizeMergeBuffer(boolean optimizeMergeBuffer) Enable/Disable merge many command's buffers to one big buffer fit socket's send buffer size.Default is true.Recommend true.voidsetPrimitiveAsString(boolean primitiveAsString) Store all primitive type as string,defualt is false.voidsetSanitizeKeys(boolean sanitizeKeys) Enables/disables sanitizing keys by URLEncoding.final voidsetServerWeight(String server, int weight) Set a memcached server's weightvoidsetTimeoutExceptionThreshold(int timeoutExceptionThreshold) Set maximum number of timeout exception for closing connection.You can set it to be a large value to disable this feature.final voidsetTranscoder(Transcoder transcoder) set transcodervoidsetWithNoReply(String key, int exp, Object value) Store key-value item to memcached,doesn't wait for reply<T> voidsetWithNoReply(String key, int exp, T value, Transcoder<T> transcoder) final voidshutdown()protected voidFor subclass override.private final voidstart0()private final voidstats(InetSocketAddress address) stats(InetSocketAddress address, long timeout) �ョ��瑰������emcached server缁��淇℃�booleanSet a new expiration time for an existing item,using default opTimeout second.booleanSet a new expiration time for an existing item<T> TwithNamespace(String ns, MemcachedClientCallable<T> callable) With the namespae to do something with current memcached client.All operations with memcached client done in callable will be under the namespace.
-
Field Details
-
log
private static final org.slf4j.Logger log -
sessionLocator
-
sessionComparator
-
shutdown
private volatile boolean shutdown -
connector
-
transcoder
-
sanitizeKeys
private boolean sanitizeKeys -
memcachedHandler
-
commandFactory
-
opTimeout
protected long opTimeout -
connectTimeout
private long connectTimeout -
connectionPoolSize
protected int connectionPoolSize -
maxQueuedNoReplyOperations
protected int maxQueuedNoReplyOperations -
resolveInetAddresses
protected boolean resolveInetAddresses -
serverOrderCount
-
authInfoMap
-
authInfoStringMap
-
name
-
failureMode
private boolean failureMode -
timeoutExceptionThreshold
private int timeoutExceptionThreshold -
stateListenerAdapters
-
shutdownHookThread
-
isHutdownHookCalled
private volatile boolean isHutdownHookCalled -
keyProvider
-
NAMESPACE_LOCAL
namespace thread local. -
CONTINUOUS_TIMEOUT_COUNTER
- See Also:
-
-
Constructor Details
-
XMemcachedClient
XMemcached constructor,default weight is 1- Parameters:
server- �����Pport- ����ㄧ���- Throws:
IOException
-
XMemcachedClient
XMemcached constructor- Parameters:
host- server hostport- server portweight- server weight- Throws:
IOException
-
XMemcachedClient
public XMemcachedClient(InetSocketAddress inetSocketAddress, int weight, CommandFactory cmdFactory) throws IOException XMemcached Constructor.- Parameters:
inetSocketAddress-weight-- Throws:
IOException
-
XMemcachedClient
- Throws:
IOException
-
XMemcachedClient
- Throws:
IOException
-
XMemcachedClient
- Throws:
IOException
-
XMemcachedClient
public XMemcachedClient(MemcachedSessionLocator locator, MemcachedSessionComparator comparator, BufferAllocator allocator, Configuration conf, Map<SocketOption, Object> socketOptions, CommandFactory commandFactory, Transcoder transcoder, Map<InetSocketAddress, InetSocketAddress> addressMap, List<MemcachedClientStateListener> stateListeners, Map<InetSocketAddress, AuthInfo> map, int poolSize, long connectTimeout, String name, boolean failureMode, boolean resolveInetAddresses) throws IOException XMemcachedClient constructor.Every server's weight is one by default. You should not new client instance by this method, use MemcachedClientBuilder instead.- Parameters:
locator-comparator-allocator-conf-commandFactory-transcoder-stateListeners-addressList-- Throws:
IOException
-
XMemcachedClient
XMemcachedClient(MemcachedSessionLocator locator, MemcachedSessionComparator comparator, BufferAllocator allocator, Configuration conf, Map<SocketOption, Object> socketOptions, CommandFactory commandFactory, Transcoder transcoder, Map<InetSocketAddress, InetSocketAddress> addressMap, int[] weights, List<MemcachedClientStateListener> stateListeners, Map<InetSocketAddress, AuthInfo> infoMap, int poolSize, long connectTimeout, String name, boolean failureMode, boolean resolveInetAddresses) throws IOException XMemcachedClient constructor.- Parameters:
locator-comparator-allocator-conf-commandFactory-transcoder-weights-stateListeners- weight array for address listaddressList-- Throws:
IOException
-
XMemcachedClient
XMemcached Constructor.Every server's weight is one by default.- Parameters:
addressList-- Throws:
IOException
-
XMemcachedClient
public XMemcachedClient(List<InetSocketAddress> addressList, CommandFactory cmdFactory) throws IOException XMemcached Constructor.Every server's weight is one by default.- Parameters:
addressList- memcached server socket address list.cmdFactory- command factory- Throws:
IOException
-
-
Method Details
-
setMergeFactor
public final void setMergeFactor(int mergeFactor) Description copied from interface:MemcachedClientSet the merge factor,this factor determins how many 'get' commands would be merge to one multi-get command.default is 150- Specified by:
setMergeFactorin interfaceMemcachedClient- Parameters:
mergeFactor-
-
getTimeoutExceptionThreshold
public int getTimeoutExceptionThreshold()Description copied from interface:MemcachedClientReturns maximum number of timeout exception for closing connection.- Specified by:
getTimeoutExceptionThresholdin interfaceMemcachedClient- Returns:
-
setTimeoutExceptionThreshold
public void setTimeoutExceptionThreshold(int timeoutExceptionThreshold) Description copied from interface:MemcachedClientSet maximum number of timeout exception for closing connection.You can set it to be a large value to disable this feature.- Specified by:
setTimeoutExceptionThresholdin interfaceMemcachedClient- Parameters:
timeoutExceptionThreshold-- See Also:
-
withNamespace
public <T> T withNamespace(String ns, MemcachedClientCallable<T> callable) throws MemcachedException, InterruptedException, TimeoutException Description copied from interface:MemcachedClientWith the namespae to do something with current memcached client.All operations with memcached client done in callable will be under the namespace.MemcachedClient.beginWithNamespace(String)andMemcachedClient.endWithNamespace()will called around automatically. For example:memcachedClient.withNamespace(userId,new MemcachedClientCallable
{ public Void call(MemcachedClient client) throws MemcachedException, InterruptedException, TimeoutException{ client.set("username",0,username); client.set("email",0,email); return null; } }); //invalidate all items under the namespace. memcachedClient.invalidateNamespace(userId); - Specified by:
withNamespacein interfaceMemcachedClient- Parameters:
ns-callable-- Returns:
- Throws:
MemcachedExceptionInterruptedExceptionTimeoutException- See Also:
-
endWithNamespace
public void endWithNamespace()Description copied from interface:MemcachedClientRemove current namespace set for this memcached client.It must begin withMemcachedClient.beginWithNamespace(String)method.- Specified by:
endWithNamespacein interfaceMemcachedClient- See Also:
-
beginWithNamespace
Description copied from interface:MemcachedClientset current namespace for following operations with memcached client.It must be ended withMemcachedClient.endWithNamespace()method.For example:memcachedClient.beginWithNamespace(userId); try { memcachedClient.set("username", 0, username); memcachedClient.set("email", 0, email); } finally { memcachedClient.endWithNamespace(); }- Specified by:
beginWithNamespacein interfaceMemcachedClient- Parameters:
ns-- See Also:
-
getKeyProvider
-
setKeyProvider
Description copied from interface:MemcachedClientSet a key provider for pre-processing keys before sending them to memcached.- Specified by:
setKeyProviderin interfaceMemcachedClient- Parameters:
keyProvider-
-
getSessionLocator
-
getSessionComparator
-
getCommandFactory
-
getName
Description copied from interface:XMemcachedClientMBeanReturn the cache instance name- Specified by:
getNamein interfaceMemcachedClient- Specified by:
getNamein interfaceXMemcachedClientMBean- Returns:
-
setName
Description copied from interface:MemcachedClientSet cache instance name- Specified by:
setNamein interfaceMemcachedClient- Parameters:
name-
-
getConnectTimeout
public long getConnectTimeout()Description copied from interface:MemcachedClientGet the connect timeout- Specified by:
getConnectTimeoutin interfaceMemcachedClient
-
setConnectTimeout
public void setConnectTimeout(long connectTimeout) Description copied from interface:MemcachedClientSet the connect timeout,default is 1 minutes- Specified by:
setConnectTimeoutin interfaceMemcachedClient- Parameters:
connectTimeout-
-
setEnableHeartBeat
public void setEnableHeartBeat(boolean enableHeartBeat) Description copied from interface:MemcachedClientWhether to enable heart beat- Specified by:
setEnableHeartBeatin interfaceMemcachedClient- Parameters:
enableHeartBeat- if true,then enable heartbeat,true by default
-
getOpTimeout
public final long getOpTimeout()get operation timeout setting- Specified by:
getOpTimeoutin interfaceMemcachedClient- Returns:
-
setOpTimeout
public final void setOpTimeout(long opTimeout) set operation timeout,default is one second.- Specified by:
setOpTimeoutin interfaceMemcachedClient- Parameters:
opTimeout-
-
setHealSessionInterval
public void setHealSessionInterval(long healConnectionInterval) Description copied from interface:MemcachedClientIf the memcached dump or network error cause connection closed,xmemcached would try to heal the connection.The interval between reconnections is 2 seconds by default. You can change that value by this method.- Specified by:
setHealSessionIntervalin interfaceMemcachedClient- Parameters:
healConnectionInterval- MILLISECONDS
-
getHealSessionInterval
public long getHealSessionInterval()Description copied from interface:MemcachedClientReturn the default heal session interval in milliseconds- Specified by:
getHealSessionIntervalin interfaceMemcachedClient- Returns:
-
getAuthInfoMap
Description copied from interface:MemcachedClientreturn current all auth info- Specified by:
getAuthInfoMapin interfaceMemcachedClient- Returns:
- Auth info map,key is memcached server address,and value is the auth info for the key.
-
setAuthInfoMap
Description copied from interface:MemcachedClientConfigure auth info- Specified by:
setAuthInfoMapin interfaceMemcachedClient- Parameters:
map- Auth info map,key is memcached server address,and value is the auth info for the key.
-
getAuthInfoStringMap
Description copied from interface:MemcachedClientRetruns the AuthInfo for all server strings (hostname:port)- Specified by:
getAuthInfoStringMapin interfaceMemcachedClient- Returns:
- A map of AuthInfos for server strings (hostname:port)
-
getConnector
Description copied from interface:MemcachedClientreturn the session manager- Specified by:
getConnectorin interfaceMemcachedClient- Returns:
-
setOptimizeMergeBuffer
public final void setOptimizeMergeBuffer(boolean optimizeMergeBuffer) Description copied from interface:MemcachedClientEnable/Disable merge many command's buffers to one big buffer fit socket's send buffer size.Default is true.Recommend true.- Specified by:
setOptimizeMergeBufferin interfaceMemcachedClient- Parameters:
optimizeMergeBuffer-
-
isShutdown
public final boolean isShutdown()- Specified by:
isShutdownin interfaceMemcachedClient- Returns:
-
gets0
private final <T> GetsResponse<T> gets0(String key, byte[] keyBytes, Transcoder<T> transcoder) throws MemcachedException, TimeoutException, InterruptedException -
sendCommand
- Throws:
MemcachedException
-
newSocketAddress
-
checkServerPort
-
addServer
Description copied from interface:MemcachedClientAadd a memcached server,the thread call this method will be blocked until the connecting operations completed(success or fail)- Specified by:
addServerin interfaceMemcachedClient- Parameters:
server- host stringport- port number- Throws:
IOException
-
addServer
add a memcached server to MemcachedClient- Specified by:
addServerin interfaceMemcachedClient- Parameters:
server-port-weight-- Throws:
IOException
-
addServer
Description copied from interface:MemcachedClientAdd a memcached server,the thread call this method will be blocked until the connecting operations completed(success or fail)- Specified by:
addServerin interfaceMemcachedClient- Parameters:
inetSocketAddress- memcached server's socket address- Throws:
IOException
-
addServer
- Specified by:
addServerin interfaceMemcachedClient- Throws:
IOException
-
addServer
Description copied from interface:XMemcachedClientMBeanAdd memcached servers- Specified by:
addServerin interfaceMemcachedClient- Specified by:
addServerin interfaceXMemcachedClientMBean- Throws:
IOException
-
addOneServerWithWeight
Description copied from interface:XMemcachedClientMBeanAdd a memcached server- Specified by:
addOneServerWithWeightin interfaceXMemcachedClientMBean- Parameters:
server- a String in the form of "[host1]:[port1],[host2]:[port2]"weight- server's weight- Throws:
IOException
-
getServersDescription
Description copied from interface:XMemcachedClientMBeanGet all connected memcached servers- Specified by:
getServersDescriptionin interfaceMemcachedClient- Specified by:
getServersDescriptionin interfaceXMemcachedClientMBean- Returns:
- a list of string,every string is in the form of "[host1]:[port1](weight=num1) [host2]:[port2](weight=num1)"
-
setServerWeight
Description copied from interface:XMemcachedClientMBeanSet a memcached server's weight- Specified by:
setServerWeightin interfaceXMemcachedClientMBean- Parameters:
server-weight-
-
removeServer
Description copied from interface:XMemcachedClientMBeanRemove memcached servers- Specified by:
removeServerin interfaceMemcachedClient- Specified by:
removeServerin interfaceXMemcachedClientMBean
-
removeServer
Description copied from interface:MemcachedClientRemove memcached server with the exact given address.- Specified by:
removeServerin interfaceMemcachedClient- Parameters:
address- Resolved server address
-
connect
- Throws:
IOException
-
fetch0
private final <T> Object fetch0(String key, byte[] keyBytes, CommandType cmdType, long timeout, Transcoder<T> transcoder) throws InterruptedException, TimeoutException, MemcachedException -
start0
- Throws:
IOException
-
startConnector
- Throws:
IOException
-
setMaxQueuedNoReplyOperations
void setMaxQueuedNoReplyOperations(int maxQueuedNoReplyOperations) Set max queued noreply operations number- Parameters:
maxQueuedNoReplyOperations-
-
buildConnector
private void buildConnector(MemcachedSessionLocator locator, MemcachedSessionComparator comparator, BufferAllocator bufferAllocator, Configuration configuration, Map<SocketOption, Object> socketOptions, CommandFactory commandFactory, Transcoder transcoder) -
newConnector
protected MemcachedConnector newConnector(BufferAllocator bufferAllocator, Configuration configuration, MemcachedSessionLocator memcachedSessionLocator, MemcachedSessionComparator memcachedSessionComparator, CommandFactory commandFactory, int poolSize, int maxQueuedNoReplyOperations) -
registerMBean
private final void registerMBean() -
setOptimizeGet
public void setOptimizeGet(boolean optimizeGet) Description copied from interface:MemcachedClientEnable/Disable merge many get commands to one multi-get command.true is to enable it,false is to disable it.Default is true.Recommend users to enable it.- Specified by:
setOptimizeGetin interfaceMemcachedClient- Parameters:
optimizeGet-
-
setBufferAllocator
Description copied from interface:MemcachedClientSet the nio's ByteBuffer Allocator,use SimpleBufferAllocator by default.- Specified by:
setBufferAllocatorin interfaceMemcachedClient- Parameters:
bufferAllocator-
-
optimiezeSetReadThreadCount
-
isWindowsPlatform
private final boolean isWindowsPlatform() -
get
public final <T> T get(String key, long timeout, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClientGet value by key- Specified by:
getin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key- Keytimeout- Operation timeout,if the method is not returned in this time,throw TimeoutExceptiontranscoder- The value's transcoder- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
get
public final <T> T get(String key, long timeout) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
getin interfaceMemcachedClient- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
get
public final <T> T get(String key, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
getin interfaceMemcachedClient- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
get
public final <T> T get(String key) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
getin interfaceMemcachedClient- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
get0
private <T> Object get0(String key, long timeout, CommandType cmdType, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException -
gets
public final <T> GetsResponse<T> gets(String key, long timeout, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClientJust like get,But it return a GetsResponse,include cas value for cas update.- Specified by:
getsin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key- keytimeout- operation timeouttranscoder-- Returns:
- GetsResponse
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
gets
public final <T> GetsResponse<T> gets(String key) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
getsin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
gets
public final <T> GetsResponse<T> gets(String key, long timeout) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
getsin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key-timeout-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
gets
public final <T> GetsResponse<T> gets(String key, Transcoder transcoder) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
getsin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key-transcoder-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
get
public final <T> Map<String,T> get(Collection<String> keyCollections, long timeout, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClientBulk get items- Specified by:
getin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
keyCollections- key collectiontimeout- opTimeouttranscoder- Value transcoder- Returns:
- Exists items map
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
get
public final <T> Map<String,T> get(Collection<String> keyCollections, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
getin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
keyCollections-transcoder-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
get
public final <T> Map<String,T> get(Collection<String> keyCollections) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
getin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
keyCollections-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
get
public final <T> Map<String,T> get(Collection<String> keyCollections, long timeout) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
getin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
keyCollections-timeout-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
gets
public final <T> Map<String, GetsResponse<T>> gets(Collection<String> keyCollections, long timeout, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClientBulk gets items- Specified by:
getsin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
keyCollections- key collectiontimeout- Operation timeouttranscoder- Value transcoder- Returns:
- Exists GetsResponse map
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
gets
public final <T> Map<String, GetsResponse<T>> gets(Collection<String> keyCollections) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
getsin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
keyCollections-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
gets
public final <T> Map<String, GetsResponse<T>> gets(Collection<String> keyCollections, long timeout) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
getsin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
keyCollections-timeout-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
gets
public final <T> Map<String, GetsResponse<T>> gets(Collection<String> keyCollections, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
getsin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
keyCollections-transcoder-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
getMulti0
private final <T> Map<String,T> getMulti0(Collection<String> keys, long timeout, CommandType cmdType, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException -
reduceResult
private <T> Map<String,T> reduceResult(CommandType cmdType, Transcoder<T> transcoder, List<Command> commands) throws MemcachedException, InterruptedException, TimeoutException -
catalogKeys
Hash key to servers- Parameters:
keyCollections-- Returns:
-
sendGetMultiCommand
private final <T> Command sendGetMultiCommand(Collection<String> keys, CountDownLatch latch, CommandType cmdType, Transcoder<T> transcoder) throws InterruptedException, TimeoutException, MemcachedException -
set
public final <T> boolean set(String key, int exp, T value, Transcoder<T> transcoder, long timeout) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClientStore key-value item to memcached- Specified by:
setin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key- stored keyexp- An expiration time, in seconds. Can be up to 30 days. After 30 days, is treated as a unix timestamp of an exact date.value- stored datatranscoder- transocdertimeout- operation timeout,in milliseconds- Returns:
- boolean result
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
setWithNoReply
public void setWithNoReply(String key, int exp, Object value) throws InterruptedException, MemcachedException Description copied from interface:MemcachedClientStore key-value item to memcached,doesn't wait for reply- Specified by:
setWithNoReplyin interfaceMemcachedClient- Parameters:
key- stored keyexp- An expiration time, in seconds. Can be up to 30 days. After 30 days, is treated as a unix timestamp of an exact date.value- stored data- Throws:
InterruptedExceptionMemcachedException
-
setWithNoReply
public <T> void setWithNoReply(String key, int exp, T value, Transcoder<T> transcoder) throws InterruptedException, MemcachedException - Specified by:
setWithNoReplyin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key-exp-value-transcoder-- Throws:
InterruptedExceptionMemcachedException- See Also:
-
checkStoreArguments
-
set
public final boolean set(String key, int exp, Object value) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
setin interfaceMemcachedClient- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
set
public final boolean set(String key, int exp, Object value, long timeout) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
setin interfaceMemcachedClient- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
set
public final <T> boolean set(String key, int exp, T value, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
setin interfaceMemcachedClient- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
add
public final <T> boolean add(String key, int exp, T value, Transcoder<T> transcoder, long timeout) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClientAdd key-value item to memcached, success only when the key is not exists in memcached.- Specified by:
addin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key-exp- An expiration time, in seconds. Can be up to 30 days. After 30 days, is treated as a unix timestamp of an exact date.value-transcoder-timeout-- Returns:
- boolean result
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
add0
private <T> boolean add0(String key, int exp, T value, Transcoder<T> transcoder, long timeout) throws InterruptedException, TimeoutException, MemcachedException -
add
public final boolean add(String key, int exp, Object value) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
addin interfaceMemcachedClient- Parameters:
key-exp-value-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
add
public final boolean add(String key, int exp, Object value, long timeout) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
addin interfaceMemcachedClient- Parameters:
key-exp-value-timeout-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
add
public final <T> boolean add(String key, int exp, T value, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
addin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key-exp-value-transcoder-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
addWithNoReply
public void addWithNoReply(String key, int exp, Object value) throws InterruptedException, MemcachedException Description copied from interface:MemcachedClientAdd key-value item to memcached, success only when the key is not exists in memcached.This method doesn't wait for reply.- Specified by:
addWithNoReplyin interfaceMemcachedClient- Parameters:
key-exp- An expiration time, in seconds. Can be up to 30 days. After 30 days, is treated as a unix timestamp of an exact date.value-- Throws:
InterruptedExceptionMemcachedException
-
addWithNoReply
public <T> void addWithNoReply(String key, int exp, T value, Transcoder<T> transcoder) throws InterruptedException, MemcachedException - Specified by:
addWithNoReplyin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key-exp-value-transcoder-- Throws:
InterruptedExceptionMemcachedException- See Also:
-
replaceWithNoReply
public void replaceWithNoReply(String key, int exp, Object value) throws InterruptedException, MemcachedException Description copied from interface:MemcachedClientReplace the key's data item in memcached,success only when the key's data item is exists in memcached.This method doesn't wait for reply from server.- Specified by:
replaceWithNoReplyin interfaceMemcachedClient- Parameters:
key-exp- An expiration time, in seconds. Can be up to 30 days. After 30 days, is treated as a unix timestamp of an exact date.value-- Throws:
InterruptedExceptionMemcachedException
-
replaceWithNoReply
public <T> void replaceWithNoReply(String key, int exp, T value, Transcoder<T> transcoder) throws InterruptedException, MemcachedException - Specified by:
replaceWithNoReplyin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key-exp-value-transcoder-- Throws:
InterruptedExceptionMemcachedException- See Also:
-
replace
public final <T> boolean replace(String key, int exp, T value, Transcoder<T> transcoder, long timeout) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClientReplace the key's data item in memcached,success only when the key's data item is exists in memcached.This method will wait for reply from server.- Specified by:
replacein interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key-exp- An expiration time, in seconds. Can be up to 30 days. After 30 days, is treated as a unix timestamp of an exact date.value-transcoder-timeout-- Returns:
- boolean result
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
replace
public final boolean replace(String key, int exp, Object value) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
replacein interfaceMemcachedClient- Parameters:
key-exp-value-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
replace
public final boolean replace(String key, int exp, Object value, long timeout) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
replacein interfaceMemcachedClient- Parameters:
key-exp-value-timeout-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
replace
public final <T> boolean replace(String key, int exp, T value, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
replacein interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key-exp-value-transcoder-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
append
public final boolean append(String key, Object value) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
appendin interfaceMemcachedClient- Parameters:
key-value-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
append
public final boolean append(String key, Object value, long timeout) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClientAppend value to key's data item,this method will wait for reply- Specified by:
appendin interfaceMemcachedClient- Parameters:
key-value-timeout-- Returns:
- boolean result
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
appendWithNoReply
public void appendWithNoReply(String key, Object value) throws InterruptedException, MemcachedException Description copied from interface:MemcachedClientAppend value to key's data item,this method doesn't wait for reply.- Specified by:
appendWithNoReplyin interfaceMemcachedClient- Parameters:
key-value-- Throws:
InterruptedExceptionMemcachedException
-
prepend
public final boolean prepend(String key, Object value) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
prependin interfaceMemcachedClient- Parameters:
key-value-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
prepend
public final boolean prepend(String key, Object value, long timeout) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClientPrepend value to key's data item in memcached.This method doesn't wait for reply.- Specified by:
prependin interfaceMemcachedClient- Parameters:
key-value-- Returns:
- boolean result
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
prependWithNoReply
public void prependWithNoReply(String key, Object value) throws InterruptedException, MemcachedException Description copied from interface:MemcachedClientPrepend value to key's data item in memcached.This method doesn't wait for reply.- Specified by:
prependWithNoReplyin interfaceMemcachedClient- Parameters:
key-value-- Throws:
InterruptedExceptionMemcachedException
-
cas
public final boolean cas(String key, int exp, Object value, long cas) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
casin interfaceMemcachedClient- Parameters:
key-exp-value-cas-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
cas
public final <T> boolean cas(String key, int exp, T value, Transcoder<T> transcoder, long timeout, long cas) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClientCas is a check and set operation which means "store this data but only if no one else has updated since I last fetched it."- Specified by:
casin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key-exp- An expiration time, in seconds. Can be up to 30 days. After 30 days, is treated as a unix timestamp of an exact date.value-transcoder-timeout-cas-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
cas
public final boolean cas(String key, int exp, Object value, long timeout, long cas) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
casin interfaceMemcachedClient- Parameters:
key-exp-value-timeout-cas-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
cas
public final <T> boolean cas(String key, int exp, T value, Transcoder<T> transcoder, long cas) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
casin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key-exp-value-transcoder-cas-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
cas0
private final <T> boolean cas0(String key, int exp, GetsResponse<T> getsResponse, CASOperation<T> operation, Transcoder<T> transcoder, byte[] keyBytes, boolean noreply) throws TimeoutException, InterruptedException, MemcachedException -
cas
public final <T> boolean cas(String key, int exp, CASOperation<T> operation, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClientCas is a check and set operation which means "store this data but only if no one else has updated since I last fetched it."- Specified by:
casin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key-exp- An expiration time, in seconds. Can be up to 30 days. After 30 days, is treated as a unix timestamp of an exact date.operation- CASOperationtranscoder- object transcoder- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
cas
public final <T> boolean cas(String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClientcas is a check and set operation which means "store this data but only if no one else has updated since I last fetched it."- Specified by:
casin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key-exp- An expiration time, in seconds. Can be up to 30 days. After 30 days, is treated as a unix timestamp of an exact date.getsReponse- gets method's resultoperation- CASOperationtranscoder-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
cas
public final <T> boolean cas(String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
casin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key-exp-getsReponse-operation-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
casWithNoReply
public <T> void casWithNoReply(String key, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
casWithNoReplyin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key-operation-- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
casWithNoReply
public <T> void casWithNoReply(String key, GetsResponse<T> getsResponse, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
casWithNoReplyin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key-getsResponse-operation-- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
casWithNoReply
public <T> void casWithNoReply(String key, int exp, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
casWithNoReplyin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key-exp-operation-- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
casWithNoReply
public <T> void casWithNoReply(String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClientcas noreply- Specified by:
casWithNoReplyin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key-exp-getsReponse-operation-- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
cas
public final <T> boolean cas(String key, GetsResponse<T> getsReponse, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
casin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key-getsReponse-operation-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
cas
public final <T> boolean cas(String key, int exp, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
casin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key-exp-operation-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
cas
public final <T> boolean cas(String key, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
casin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key-operation-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
delete
public final boolean delete(String key, int time) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClientDelete key's data item from memcached.It it is not exists,return false. time is 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. Note: This method is deprecated,because memcached 1.4.0 remove the optional argument "time".You can still use this method on old version,but is not recommended.- Specified by:
deletein interfaceMemcachedClient- Parameters:
key-time-- Throws:
InterruptedExceptionMemcachedExceptionTimeoutException
-
delete
public boolean delete(String key, long opTimeout) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClientDelete key's date item from memcached- Specified by:
deletein interfaceMemcachedClient- Parameters:
key-opTimeout- Operation timeout- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
delete
public boolean delete(String key, long cas, long opTimeout) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClientDelete key's date item from memcached only if its cas value is the same as what was read.- Specified by:
deletein interfaceMemcachedClient- Parameters:
key-opTimeout- Operation timeout- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
deleteWithNoReply
public final void deleteWithNoReply(String key, int time) throws InterruptedException, MemcachedException Delete key's data item from memcached.This method doesn't wait for reply- Specified by:
deleteWithNoReplyin interfaceMemcachedClient- Parameters:
key-time-- Throws:
InterruptedExceptionMemcachedException
-
deleteWithNoReply
- Specified by:
deleteWithNoReplyin interfaceMemcachedClient- Throws:
InterruptedExceptionMemcachedException
-
delete0
private boolean delete0(String key, int time, long cas, boolean noreply, long opTimeout) throws MemcachedException, InterruptedException, TimeoutException -
checkException
- Throws:
MemcachedException
-
touch
public boolean touch(String key, int exp, long opTimeout) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClientSet a new expiration time for an existing item- Specified by:
touchin interfaceMemcachedClient- Parameters:
key- item's keyexp- New expiration time, in seconds. Can be up to 30 days. After 30 days, is treated as a unix timestamp of an exact date.opTimeout- operation timeout- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
touch
public boolean touch(String key, int exp) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClientSet a new expiration time for an existing item,using default opTimeout second.- Specified by:
touchin interfaceMemcachedClient- Parameters:
key- item's keyexp- New expiration time, in seconds. Can be up to 30 days. After 30 days, is treated as a unix timestamp of an exact date.- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
getAndTouch
public <T> T getAndTouch(String key, int newExp, long opTimeout) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClientGet item and set a new expiration time for it- Specified by:
getAndTouchin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key- item's keynewExp- New expiration time, in seconds. Can be up to 30 days. After 30 days, is treated as a unix timestamp of an exact date.opTimeout- operation timeout- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
getAndTouch
public <T> T getAndTouch(String key, int newExp) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClientGet item and set a new expiration time for it,using default opTimeout- Specified by:
getAndTouchin interfaceMemcachedClient- Type Parameters:
T-- Parameters:
key-newExp-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
incr
public final long incr(String key, long delta) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClient"incr" are used to change data for some item in-place, incrementing it. The data for the item is treated as decimal representation of a 64-bit unsigned integer. If the current data value does not conform to such a representation, the commands behave as if the value were 0. Also, the item must already exist for incr to work; these commands won't pretend that a non-existent key exists with value 0; instead, it will fail.This method doesn't wait for reply.- Specified by:
incrin interfaceMemcachedClient- Parameters:
key-- Returns:
- the new value of the item's data, after the increment operation was carried out.
- Throws:
InterruptedExceptionMemcachedExceptionTimeoutException
-
incr
public long incr(String key, long delta, long initValue) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
incrin interfaceMemcachedClient- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
incr
public long incr(String key, long delta, long initValue, long timeout) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClient"incr" are used to change data for some item in-place, incrementing it. The data for the item is treated as decimal representation of a 64-bit unsigned integer. If the current data value does not conform to such a representation, the commands behave as if the value were 0. Also, the item must already exist for incr to work; these commands won't pretend that a non-existent key exists with value 0; instead, it will fail.This method doesn't wait for reply.- Specified by:
incrin interfaceMemcachedClient- Parameters:
key- keyinitValue- initValue if the data is not exists.timeout- operation timeout- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
incr
public long incr(String key, long delta, long initValue, long timeout, int exp) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClient"incr" are used to change data for some item in-place, incrementing it. The data for the item is treated as decimal representation of a 64-bit unsigned integer. If the current data value does not conform to such a representation, the commands behave as if the value were 0. Also, the item must already exist for incr to work; these commands won't pretend that a non-existent key exists with value 0; instead, it will fail.This method doesn't wait for reply.- Specified by:
incrin interfaceMemcachedClient- Parameters:
key- keydelta- increment deltainitValue- the initial value to be added when value is not foundtimeout- operation timeoutexp- the initial vlaue expire time, in seconds. Can be up to 30 days. After 30 days, is treated as a unix timestamp of an exact date.- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
incrWithNoReply
public final void incrWithNoReply(String key, long delta) throws InterruptedException, MemcachedException Description copied from interface:MemcachedClient"incr" are used to change data for some item in-place, incrementing it. The data for the item is treated as decimal representation of a 64-bit unsigned integer. If the current data value does not conform to such a representation, the commands behave as if the value were 0. Also, the item must already exist for incr to work; these commands won't pretend that a non-existent key exists with value 0; instead, it will fail.This method doesn't wait for reply.- Specified by:
incrWithNoReplyin interfaceMemcachedClient- Parameters:
key-- Throws:
InterruptedExceptionMemcachedException
-
decrWithNoReply
public final void decrWithNoReply(String key, long delta) throws InterruptedException, MemcachedException Description copied from interface:MemcachedClient"decr" are used to change data for some item in-place, decrementing it. The data for the item is treated as decimal representation of a 64-bit unsigned integer. If the current data value does not conform to such a representation, the commands behave as if the value were 0. Also, the item must already exist for decr to work; these commands won't pretend that a non-existent key exists with value 0; instead, it will fail.This method doesn't wait for reply.- Specified by:
decrWithNoReplyin interfaceMemcachedClient- Parameters:
key-- Throws:
InterruptedExceptionMemcachedException
-
decr
public final long decr(String key, long delta) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClient"decr" are used to change data for some item in-place, decrementing it. The data for the item is treated as decimal representation of a 64-bit unsigned integer. If the current data value does not conform to such a representation, the commands behave as if the value were 0. Also, the item must already exist for decr to work; these commands won't pretend that a non-existent key exists with value 0; instead, it will fail.This method doesn't wait for reply.- Specified by:
decrin interfaceMemcachedClient- Parameters:
key-- Returns:
- the new value of the item's data, after the decrement operation was carried out.
- Throws:
InterruptedExceptionMemcachedExceptionTimeoutException
-
decr
public long decr(String key, long delta, long initValue) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
decrin interfaceMemcachedClient- Parameters:
key-initValue-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException- See Also:
-
decr
public long decr(String key, long delta, long initValue, long timeout) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClient"decr" are used to change data for some item in-place, decrementing it. The data for the item is treated as decimal representation of a 64-bit unsigned integer. If the current data value does not conform to such a representation, the commands behave as if the value were 0. Also, the item must already exist for decr to work; these commands won't pretend that a non-existent key exists with value 0; instead, it will fail.This method doesn't wait for reply.- Specified by:
decrin interfaceMemcachedClient- Parameters:
key- The keyinitValue- The initial value if the data is not exists.timeout- Operation timeout- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
decr
public long decr(String key, long delta, long initValue, long timeout, int exp) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClient"incr" are used to change data for some item in-place, incrementing it. The data for the item is treated as decimal representation of a 64-bit unsigned integer. If the current data value does not conform to such a representation, the commands behave as if the value were 0. Also, the item must already exist for incr to work; these commands won't pretend that a non-existent key exists with value 0; instead, it will fail.This method doesn't wait for reply.- Specified by:
decrin interfaceMemcachedClient- Parameters:
key-delta-initValue- the initial value to be added when value is not foundtimeout-exp- the initial vlaue expire time, in seconds. Can be up to 30 days. After 30 days, is treated as a unix timestamp of an exact date.- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
flushAll
Description copied from interface:MemcachedClientMake All connected memcached's data item invalid- Specified by:
flushAllin interfaceMemcachedClient- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
flushAllWithNoReply
- Specified by:
flushAllWithNoReplyin interfaceMemcachedClient- Throws:
InterruptedExceptionMemcachedException
-
flushAllWithNoReply
- Specified by:
flushAllWithNoReplyin interfaceMemcachedClient- Throws:
InterruptedExceptionMemcachedException
-
flushAllWithNoReply
public void flushAllWithNoReply(InetSocketAddress address) throws MemcachedException, InterruptedException - Specified by:
flushAllWithNoReplyin interfaceMemcachedClient- Throws:
MemcachedExceptionInterruptedException
-
flushAllWithNoReply
public void flushAllWithNoReply(InetSocketAddress address, int exptime) throws MemcachedException, InterruptedException - Specified by:
flushAllWithNoReplyin interfaceMemcachedClient- Throws:
MemcachedExceptionInterruptedException
-
flushAll
public final void flushAll(int exptime, long timeout) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
flushAllin interfaceMemcachedClient- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
flushAll
public final void flushAll(long timeout) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClientMake All connected memcached's data item invalid- Specified by:
flushAllin interfaceMemcachedClient- Parameters:
timeout- operation timeout- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
flushAllMemcachedServers
private void flushAllMemcachedServers(long timeout, boolean noreply, int exptime) throws MemcachedException, InterruptedException, TimeoutException -
setLoggingLevelVerbosity
public void setLoggingLevelVerbosity(InetSocketAddress address, int level) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClientSet the verbosity level of the memcached's logging output.This method will wait for reply.- Specified by:
setLoggingLevelVerbosityin interfaceMemcachedClient- Parameters:
address-level- logging level- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
setMemcachedLoggingLevel
private void setMemcachedLoggingLevel(InetSocketAddress address, int level, boolean noreply) throws MemcachedException, InterruptedException, TimeoutException -
setLoggingLevelVerbosityWithNoReply
public void setLoggingLevelVerbosityWithNoReply(InetSocketAddress address, int level) throws InterruptedException, MemcachedException Description copied from interface:MemcachedClientSet the verbosity level of the memcached's logging output.This method doesn't wait for reply from server- Specified by:
setLoggingLevelVerbosityWithNoReplyin interfaceMemcachedClient- Parameters:
address- memcached server addresslevel- logging level- Throws:
InterruptedExceptionMemcachedException
-
flushAll
public final void flushAll(InetSocketAddress address) throws MemcachedException, InterruptedException, TimeoutException Description copied from interface:MemcachedClientInvalidate all existing items immediately- Specified by:
flushAllin interfaceMemcachedClient- Parameters:
address- Target memcached server- Throws:
MemcachedExceptionInterruptedExceptionTimeoutException
-
flushAll
public final void flushAll(InetSocketAddress address, long timeout) throws MemcachedException, InterruptedException, TimeoutException - Specified by:
flushAllin interfaceMemcachedClient- Throws:
MemcachedExceptionInterruptedExceptionTimeoutException
-
flushAll
public final void flushAll(InetSocketAddress address, long timeout, int exptime) throws MemcachedException, InterruptedException, TimeoutException - Specified by:
flushAllin interfaceMemcachedClient- Throws:
MemcachedExceptionInterruptedExceptionTimeoutException
-
flushSpecialMemcachedServer
private void flushSpecialMemcachedServer(InetSocketAddress address, long timeout, boolean noreply, int exptime) throws MemcachedException, InterruptedException, TimeoutException -
flushAll
public final void flushAll(String host) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClientThis method is deprecated,please use flushAll(InetSocketAddress) instead.- Specified by:
flushAllin interfaceMemcachedClient- Parameters:
host-- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
stats
public final Map<String,String> stats(InetSocketAddress address) throws MemcachedException, InterruptedException, TimeoutException - Specified by:
statsin interfaceMemcachedClient- Throws:
MemcachedExceptionInterruptedExceptionTimeoutException
-
stats
public final Map<String,String> stats(InetSocketAddress address, long timeout) throws MemcachedException, InterruptedException, TimeoutException Description copied from interface:MemcachedClient�ョ��瑰������emcached server缁��淇℃�- Specified by:
statsin interfaceMemcachedClient- Parameters:
address- ����板�timeout- ���瓒��- Returns:
- Throws:
MemcachedExceptionInterruptedExceptionTimeoutException
-
getStats
public final Map<InetSocketAddress, Map<String,String>> getStats() throws MemcachedException, InterruptedException, TimeoutException- Specified by:
getStatsin interfaceMemcachedClient- Throws:
MemcachedExceptionInterruptedExceptionTimeoutException
-
getStatsByItem
public final Map<InetSocketAddress, Map<String,String>> getStatsByItem(String itemName) throws MemcachedException, InterruptedException, TimeoutException Description copied from interface:MemcachedClientGet special item stats. "stats items" for example- Specified by:
getStatsByItemin interfaceMemcachedClient- Returns:
- Throws:
MemcachedExceptionInterruptedExceptionTimeoutException
-
getStatsByItem
public final Map<InetSocketAddress, Map<String,String>> getStatsByItem(String itemName, long timeout) throws MemcachedException, InterruptedException, TimeoutException - Specified by:
getStatsByItemin interfaceMemcachedClient- Throws:
MemcachedExceptionInterruptedExceptionTimeoutException
-
getVersions
public final Map<InetSocketAddress, String> getVersions() throws TimeoutException, InterruptedException, MemcachedExceptionDescription copied from interface:MemcachedClientGet all connected memcached servers's version.- Specified by:
getVersionsin interfaceMemcachedClient- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
getVersions
public final Map<InetSocketAddress, String> getVersions(long timeout) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
getVersionsin interfaceMemcachedClient- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
getStats
public Map<InetSocketAddress, Map<String,String>> getStats(long timeout) throws MemcachedException, InterruptedException, TimeoutException Description copied from interface:MemcachedClientGet stats from all memcached servers- Specified by:
getStatsin interfaceMemcachedClient- Parameters:
timeout-- Returns:
- server->item->value map
- Throws:
MemcachedExceptionInterruptedExceptionTimeoutException
-
shutdown0
protected void shutdown0()For subclass override. -
shutdown
- Specified by:
shutdownin interfaceMemcachedClient- Throws:
IOException
-
sendIncrOrDecrCommand
private long sendIncrOrDecrCommand(String key, long delta, long initValue, CommandType cmdType, boolean noreply, long operationTimeout, int exp) throws InterruptedException, TimeoutException, MemcachedException -
setConnectionPoolSize
public void setConnectionPoolSize(int poolSize) Description copied from interface:MemcachedClientIn a high concurrent enviroment,you may want to pool memcached clients.But a xmemcached client has to start a reactor thread and some thread pools,if you create too many clients,the cost is very large. Xmemcached supports connection pool instreadof client pool.you can create more connections to one or more memcached servers,and these connections share the same reactor and thread pools,it will reduce the cost of system.- Specified by:
setConnectionPoolSizein interfaceMemcachedClient- Parameters:
poolSize- pool size,default is one,every memcached has only one connection.
-
delete
public final boolean delete(String key) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
deletein interfaceMemcachedClient- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
getTranscoder
Description copied from interface:MemcachedClientreturn default transcoder,default is SerializingTranscoder- Specified by:
getTranscoderin interfaceMemcachedClient- Returns:
-
setTranscoder
Description copied from interface:MemcachedClientset transcoder- Specified by:
setTranscoderin interfaceMemcachedClient- Parameters:
transcoder-
-
sendStoreCommand
private final <T> boolean sendStoreCommand(Command command, long timeout) throws InterruptedException, TimeoutException, MemcachedException -
latchWait
protected void latchWait(Command cmd, long timeout, Session session) throws InterruptedException, TimeoutException - Throws:
InterruptedExceptionTimeoutException
-
getContinuousTimeoutCounter
-
getAvaliableServers
Deprecated.Use getAvailableServers() instead- Specified by:
getAvaliableServersin interfaceMemcachedClient- Returns:
- See Also:
-
getAvailableServers
Description copied from interface:MemcachedClientReturns available memcached servers list.- Specified by:
getAvailableServersin interfaceMemcachedClient- Returns:
- A available server collection
-
getConnectionSizeBySocketAddress
-
addStateListener
Description copied from interface:MemcachedClientAdd a memcached client listener- Specified by:
addStateListenerin interfaceMemcachedClient- Parameters:
listener-
-
getStateListeners
Description copied from interface:MemcachedClientGet all current state listeners- Specified by:
getStateListenersin interfaceMemcachedClient- Returns:
-
setPrimitiveAsString
public void setPrimitiveAsString(boolean primitiveAsString) Description copied from interface:MemcachedClientStore all primitive type as string,defualt is false.- Specified by:
setPrimitiveAsStringin interfaceMemcachedClient
-
removeStateListener
Description copied from interface:MemcachedClientRemove a memcached client listener- Specified by:
removeStateListenerin interfaceMemcachedClient- Parameters:
listener-
-
getProtocol
- Specified by:
getProtocolin interfaceMemcachedClient
-
isSanitizeKeys
public boolean isSanitizeKeys()- Specified by:
isSanitizeKeysin interfaceMemcachedClient
-
setSanitizeKeys
public void setSanitizeKeys(boolean sanitizeKeys) Description copied from interface:MemcachedClientEnables/disables sanitizing keys by URLEncoding.- Specified by:
setSanitizeKeysin interfaceMemcachedClient- Parameters:
sanitizeKeys- if true, then URLEncode all keys
-
decodeKey
private String decodeKey(String key) throws MemcachedException, InterruptedException, TimeoutException -
preProcessKey
-
invalidateNamespace
public void invalidateNamespace(String ns, long opTimeout) throws MemcachedException, InterruptedException, TimeoutException Description copied from interface:MemcachedClientInvalidate all items under the namespace.- Specified by:
invalidateNamespacein interfaceMemcachedClient- Parameters:
ns- the namespaceopTimeout- operation timeout in milliseconds.- Throws:
MemcachedExceptionInterruptedExceptionTimeoutException
-
invalidateNamespace
public void invalidateNamespace(String ns) throws MemcachedException, InterruptedException, TimeoutException Description copied from interface:MemcachedClientInvalidate all namespace under the namespace using the default operation timeout.- Specified by:
invalidateNamespacein interfaceMemcachedClient- Parameters:
ns- the namespace- Throws:
MemcachedExceptionInterruptedExceptionTimeoutException
-
getNamespace
public String getNamespace(String ns) throws TimeoutException, InterruptedException, MemcachedException Returns the real namespace of ns.- Parameters:
ns-- Returns:
- Throws:
TimeoutExceptionInterruptedExceptionMemcachedException
-
getNSKey
-
getCounter
Description copied from interface:MemcachedClientGet counter for key,and if the key's value is not set,then set it with initial value.- Specified by:
getCounterin interfaceMemcachedClient- Parameters:
key-initialValue-- Returns:
-
getCounter
Description copied from interface:MemcachedClientGet counter for key,and if the key's value is not set,then set it with 0.- Specified by:
getCounterin interfaceMemcachedClient- Parameters:
key-- Returns:
-
getKeyIterator
@Deprecated public KeyIterator getKeyIterator(InetSocketAddress address) throws MemcachedException, TimeoutException, InterruptedException Deprecated.memcached 1.6.x will remove cachedump stats command,so this method will be removed in the futureDescription copied from interface:MemcachedClientGet key iterator for special memcached server.You must known that the iterator is a snapshot for memcached all keys,it is not real-time.The 'stats cachedump" has length limitation,so iterator could not visit all keys if you have many keys.Your application should not be dependent on this feature.- Specified by:
getKeyIteratorin interfaceMemcachedClient- Parameters:
address-- Returns:
- Throws:
MemcachedExceptionTimeoutExceptionInterruptedException
-
setEnableHealSession
public void setEnableHealSession(boolean enableHealSession) Description copied from interface:MemcachedClientIf the memcached dump or network error cause connection closed,xmemcached would try to heal the connection.You can disable this behaviour by using this method:
client.setEnableHealSession(false);
The default value is true.- Specified by:
setEnableHealSessionin interfaceMemcachedClient- Parameters:
enableHealSession-
-
setFailureMode
public void setFailureMode(boolean failureMode) Description copied from interface:MemcachedClientConfigure wheather to set client in failure mode.If set it to true,that means you want to configure client in failure mode. Failure mode is that when a memcached server is down,it would not taken from the server list but marked as unavailable,and then further requests to this server will be transformed to standby node if configured or throw an exception until it comes back up.- Specified by:
setFailureModein interfaceMemcachedClient- Parameters:
failureMode- true is to configure client in failure mode.
-
isFailureMode
public boolean isFailureMode()Description copied from interface:MemcachedClientReturns if client is in failure mode.- Specified by:
isFailureModein interfaceMemcachedClient- Returns:
-
getReconnectRequestQueue
Description copied from interface:MemcachedClientReturns reconnecting task queue,the queue is thread-safe and 'weakly consistent',but maybe you should not modify it at all.- Specified by:
getReconnectRequestQueuein interfaceMemcachedClient- Returns:
- The reconnecting task queue,if the client has not been started,returns null.
-