Package net.rubyeye.xmemcached
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 CommandFactory
protected int
protected MemcachedConnector
private long
private static final String
private boolean
private boolean
private KeyProvider
private static final org.slf4j.Logger
protected int
private MemcachedHandler
private String
static final ThreadLocal
<String> namespace thread local.protected long
protected boolean
private boolean
protected final AtomicInteger
protected MemcachedSessionComparator
protected MemcachedSessionLocator
private boolean
private Thread
private final CopyOnWriteArrayList
<MemcachedClientStateListenerAdapter> private int
private Transcoder
Fields inherited from interface net.rubyeye.xmemcached.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 boolean
final boolean
final <T> boolean
add
(String key, int exp, T value, Transcoder<T> transcoder) final <T> boolean
add
(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> boolean
add0
(String key, int exp, T value, Transcoder<T> transcoder, long timeout) void
addOneServerWithWeight
(String server, int weight) Add a memcached serverfinal void
Add memcached serversfinal void
Aadd a memcached server,the thread call this method will be blocked until the connecting operations completed(success or fail)final void
add a memcached server to MemcachedClientfinal void
addServer
(InetSocketAddress inetSocketAddress) Add a memcached server,the thread call this method will be blocked until the connecting operations completed(success or fail)final void
addServer
(InetSocketAddress inetSocketAddress, int weight) void
addStateListener
(MemcachedClientStateListener listener) Add a memcached client listenervoid
addWithNoReply
(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> void
addWithNoReply
(String key, int exp, T value, Transcoder<T> transcoder) final boolean
final boolean
Append value to key's data item,this method will wait for replyvoid
appendWithNoReply
(String key, Object value) Append value to key's data item,this method doesn't wait for reply.void
set current namespace for following operations with memcached client.It must be ended withMemcachedClient.endWithNamespace()
method.For example:private void
buildConnector
(MemcachedSessionLocator locator, MemcachedSessionComparator comparator, BufferAllocator bufferAllocator, Configuration configuration, Map<SocketOption, Object> socketOptions, CommandFactory commandFactory, Transcoder transcoder) final boolean
final boolean
final <T> boolean
cas
(String key, int exp, CASOperation<T> operation) final <T> boolean
cas
(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> boolean
cas
(String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation) final <T> boolean
cas
(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> boolean
cas
(String key, int exp, T value, Transcoder<T> transcoder, long cas) final <T> boolean
cas
(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> boolean
cas
(String key, CASOperation<T> operation) final <T> boolean
cas
(String key, GetsResponse<T> getsReponse, CASOperation<T> operation) private final <T> boolean
cas0
(String key, int exp, GetsResponse<T> getsResponse, CASOperation<T> operation, Transcoder<T> transcoder, byte[] keyBytes, boolean noreply) <T> void
casWithNoReply
(String key, int exp, CASOperation<T> operation) <T> void
casWithNoReply
(String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation) cas noreply<T> void
casWithNoReply
(String key, CASOperation<T> operation) <T> void
casWithNoReply
(String key, GetsResponse<T> getsResponse, CASOperation<T> operation) private final Collection
<List<String>> catalogKeys
(Collection<String> keyCollections) Hash key to serversprotected void
checkException
(Command command) private void
checkServerPort
(String server, int port) private final <T> byte[]
checkStoreArguments
(String key, int exp, T value) protected void
connect
(InetSocketAddressWrapper inetSocketAddressWrapper) private String
final long
"decr" are used to change data for some item in-place, decrementing it.long
long
"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 void
decrWithNoReply
(String key, long delta) "decr" are used to change data for some item in-place, decrementing it.final boolean
final boolean
Delete 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.boolean
Delete key's date item from memcachedboolean
Delete key's date item from memcached only if its cas value is the same as what was read.private boolean
final void
deleteWithNoReply
(String key) final void
deleteWithNoReply
(String key, int time) Delete key's data item from memcached.This method doesn't wait for replyvoid
Remove current namespace set for this memcached client.It must begin withMemcachedClient.beginWithNamespace(String)
method.private final <T> Object
fetch0
(String key, byte[] keyBytes, CommandType cmdType, long timeout, Transcoder<T> transcoder) final void
flushAll()
Make All connected memcached's data item invalidfinal void
flushAll
(int exptime, long timeout) final void
flushAll
(long timeout) Make All connected memcached's data item invalidfinal void
This method is deprecated,please use flushAll(InetSocketAddress) instead.final void
flushAll
(InetSocketAddress address) Invalidate all existing items immediatelyfinal void
flushAll
(InetSocketAddress address, long timeout) final void
flushAll
(InetSocketAddress address, long timeout, int exptime) private void
flushAllMemcachedServers
(long timeout, boolean noreply, int exptime) void
void
flushAllWithNoReply
(int exptime) void
flushAllWithNoReply
(InetSocketAddress address) void
flushAllWithNoReply
(InetSocketAddress address, int exptime) private void
flushSpecialMemcachedServer
(InetSocketAddress address, long timeout, boolean noreply, int exptime) final <T> T
final <T> T
final <T> T
get
(String key, long timeout, Transcoder<T> transcoder) Get value by keyfinal <T> T
get
(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> Object
get0
(String key, long timeout, CommandType cmdType, Transcoder<T> transcoder) <T> T
getAndTouch
(String key, int newExp) Get item and set a new expiration time for it,using default opTimeout<T> T
getAndTouch
(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 CommandFactory
final int
final Connector
return the session managerlong
Get the connect timeoutprivate AtomicInteger
getContinuousTimeoutCounter
(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.long
Return 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 String
final long
get 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 MemcachedSessionLocator
Get 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) int
Returns maximum number of timeout exception for closing connection.final Transcoder
return 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.long
long
"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 void
incrWithNoReply
(String key, long delta) "incr" are used to change data for some item in-place, incrementing it.void
Invalidate all namespace under the namespace using the default operation timeout.void
invalidateNamespace
(String ns, long opTimeout) Invalidate all items under the namespace.boolean
Returns if client is in failure mode.boolean
final boolean
private final boolean
protected void
protected MemcachedConnector
newConnector
(BufferAllocator bufferAllocator, Configuration configuration, MemcachedSessionLocator memcachedSessionLocator, MemcachedSessionComparator memcachedSessionComparator, CommandFactory commandFactory, int poolSize, int maxQueuedNoReplyOperations) protected InetSocketAddress
newSocketAddress
(String server, int port) private final void
optimiezeSetReadThreadCount
(Configuration conf, int addressCount) final boolean
final boolean
Prepend value to key's data item in memcached.This method doesn't wait for reply.void
prependWithNoReply
(String key, Object value) Prepend value to key's data item in memcached.This method doesn't wait for reply.private String
preProcessKey
(String key) reduceResult
(CommandType cmdType, Transcoder<T> transcoder, List<Command> commands) private final void
final void
removeServer
(String hostList) Remove memcached serversvoid
removeServer
(InetSocketAddress address) Remove memcached server with the exact given address.void
Remove a memcached client listenerfinal boolean
final boolean
final <T> boolean
replace
(String key, int exp, T value, Transcoder<T> transcoder) final <T> boolean
replace
(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.void
replaceWithNoReply
(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> void
replaceWithNoReply
(String key, int exp, T value, Transcoder<T> transcoder) protected final Session
sendCommand
(Command cmd) private final <T> Command
sendGetMultiCommand
(Collection<String> keys, CountDownLatch latch, CommandType cmdType, Transcoder<T> transcoder) private long
sendIncrOrDecrCommand
(String key, long delta, long initValue, CommandType cmdType, boolean noreply, long operationTimeout, int exp) private final <T> boolean
sendStoreCommand
(Command command, long timeout) final boolean
final boolean
final <T> boolean
set
(String key, int exp, T value, Transcoder<T> transcoder) final <T> boolean
set
(String key, int exp, T value, Transcoder<T> transcoder, long timeout) Store key-value item to memcachedvoid
Configure auth infofinal void
setBufferAllocator
(BufferAllocator bufferAllocator) Set the nio's ByteBuffer Allocator,use SimpleBufferAllocator by default.void
setConnectionPoolSize
(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.void
setConnectTimeout
(long connectTimeout) Set the connect timeout,default is 1 minutesvoid
setEnableHealSession
(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.void
setEnableHeartBeat
(boolean enableHeartBeat) Whether to enable heart beatvoid
setFailureMode
(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.void
setHealSessionInterval
(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.void
setKeyProvider
(KeyProvider keyProvider) Set a key provider for pre-processing keys before sending them to memcached.void
setLoggingLevelVerbosity
(InetSocketAddress address, int level) Set the verbosity level of the memcached's logging output.This method will wait for reply.void
setLoggingLevelVerbosityWithNoReply
(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) void
setMaxQueuedNoReplyOperations
(int maxQueuedNoReplyOperations) Set max queued noreply operations numberprivate void
setMemcachedLoggingLevel
(InetSocketAddress address, int level, boolean noreply) final void
setMergeFactor
(int mergeFactor) Set the merge factor,this factor determins how many 'get' commands would be merge to one multi-get command.default is 150void
Set cache instance namefinal void
setOpTimeout
(long opTimeout) set operation timeout,default is one second.void
setOptimizeGet
(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 void
setOptimizeMergeBuffer
(boolean optimizeMergeBuffer) Enable/Disable merge many command's buffers to one big buffer fit socket's send buffer size.Default is true.Recommend true.void
setPrimitiveAsString
(boolean primitiveAsString) Store all primitive type as string,defualt is false.void
setSanitizeKeys
(boolean sanitizeKeys) Enables/disables sanitizing keys by URLEncoding.final void
setServerWeight
(String server, int weight) Set a memcached server's weightvoid
setTimeoutExceptionThreshold
(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 void
setTranscoder
(Transcoder transcoder) set transcodervoid
setWithNoReply
(String key, int exp, Object value) Store key-value item to memcached,doesn't wait for reply<T> void
setWithNoReply
(String key, int exp, T value, Transcoder<T> transcoder) final void
shutdown()
protected void
For subclass override.private final void
start0()
private final void
stats
(InetSocketAddress address) stats
(InetSocketAddress address, long timeout) �ョ��瑰������emcached server缁��淇℃�boolean
Set a new expiration time for an existing item,using default opTimeout second.boolean
Set a new expiration time for an existing item<T> T
withNamespace
(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, throws IOExceptionInetSocketAddress> 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. 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, throws IOExceptionInetSocketAddress> addressMap, int[] weights, List<MemcachedClientStateListener> stateListeners, Map<InetSocketAddress, AuthInfo> infoMap, int poolSize, long connectTimeout, String name, boolean failureMode, boolean resolveInetAddresses) 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:MemcachedClient
Set the merge factor,this factor determins how many 'get' commands would be merge to one multi-get command.default is 150- Specified by:
setMergeFactor
in interfaceMemcachedClient
- Parameters:
mergeFactor
-
-
getTimeoutExceptionThreshold
public int getTimeoutExceptionThreshold()Description copied from interface:MemcachedClient
Returns maximum number of timeout exception for closing connection.- Specified by:
getTimeoutExceptionThreshold
in interfaceMemcachedClient
- Returns:
-
setTimeoutExceptionThreshold
public void setTimeoutExceptionThreshold(int timeoutExceptionThreshold) Description copied from interface:MemcachedClient
Set maximum number of timeout exception for closing connection.You can set it to be a large value to disable this feature.- Specified by:
setTimeoutExceptionThreshold
in interfaceMemcachedClient
- Parameters:
timeoutExceptionThreshold
-- See Also:
-
withNamespace
public <T> T withNamespace(String ns, MemcachedClientCallable<T> callable) throws MemcachedException, InterruptedException, TimeoutException Description copied from interface:MemcachedClient
With 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:
withNamespace
in interfaceMemcachedClient
- Parameters:
ns
-callable
-- Returns:
- Throws:
MemcachedException
InterruptedException
TimeoutException
- See Also:
-
endWithNamespace
public void endWithNamespace()Description copied from interface:MemcachedClient
Remove current namespace set for this memcached client.It must begin withMemcachedClient.beginWithNamespace(String)
method.- Specified by:
endWithNamespace
in interfaceMemcachedClient
- See Also:
-
beginWithNamespace
Description copied from interface:MemcachedClient
set 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:
beginWithNamespace
in interfaceMemcachedClient
- Parameters:
ns
-- See Also:
-
getKeyProvider
-
setKeyProvider
Description copied from interface:MemcachedClient
Set a key provider for pre-processing keys before sending them to memcached.- Specified by:
setKeyProvider
in interfaceMemcachedClient
- Parameters:
keyProvider
-
-
getSessionLocator
-
getSessionComparator
-
getCommandFactory
-
getName
Description copied from interface:XMemcachedClientMBean
Return the cache instance name- Specified by:
getName
in interfaceMemcachedClient
- Specified by:
getName
in interfaceXMemcachedClientMBean
- Returns:
-
setName
Description copied from interface:MemcachedClient
Set cache instance name- Specified by:
setName
in interfaceMemcachedClient
- Parameters:
name
-
-
getConnectTimeout
public long getConnectTimeout()Description copied from interface:MemcachedClient
Get the connect timeout- Specified by:
getConnectTimeout
in interfaceMemcachedClient
-
setConnectTimeout
public void setConnectTimeout(long connectTimeout) Description copied from interface:MemcachedClient
Set the connect timeout,default is 1 minutes- Specified by:
setConnectTimeout
in interfaceMemcachedClient
- Parameters:
connectTimeout
-
-
setEnableHeartBeat
public void setEnableHeartBeat(boolean enableHeartBeat) Description copied from interface:MemcachedClient
Whether to enable heart beat- Specified by:
setEnableHeartBeat
in interfaceMemcachedClient
- Parameters:
enableHeartBeat
- if true,then enable heartbeat,true by default
-
getOpTimeout
public final long getOpTimeout()get operation timeout setting- Specified by:
getOpTimeout
in interfaceMemcachedClient
- Returns:
-
setOpTimeout
public final void setOpTimeout(long opTimeout) set operation timeout,default is one second.- Specified by:
setOpTimeout
in interfaceMemcachedClient
- Parameters:
opTimeout
-
-
setHealSessionInterval
public void setHealSessionInterval(long healConnectionInterval) Description copied from interface:MemcachedClient
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. You can change that value by this method.- Specified by:
setHealSessionInterval
in interfaceMemcachedClient
- Parameters:
healConnectionInterval
- MILLISECONDS
-
getHealSessionInterval
public long getHealSessionInterval()Description copied from interface:MemcachedClient
Return the default heal session interval in milliseconds- Specified by:
getHealSessionInterval
in interfaceMemcachedClient
- Returns:
-
getAuthInfoMap
Description copied from interface:MemcachedClient
return current all auth info- Specified by:
getAuthInfoMap
in interfaceMemcachedClient
- Returns:
- Auth info map,key is memcached server address,and value is the auth info for the key.
-
setAuthInfoMap
Description copied from interface:MemcachedClient
Configure auth info- Specified by:
setAuthInfoMap
in 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:MemcachedClient
Retruns the AuthInfo for all server strings (hostname:port)- Specified by:
getAuthInfoStringMap
in interfaceMemcachedClient
- Returns:
- A map of AuthInfos for server strings (hostname:port)
-
getConnector
Description copied from interface:MemcachedClient
return the session manager- Specified by:
getConnector
in interfaceMemcachedClient
- Returns:
-
setOptimizeMergeBuffer
public final void setOptimizeMergeBuffer(boolean optimizeMergeBuffer) Description copied from interface:MemcachedClient
Enable/Disable merge many command's buffers to one big buffer fit socket's send buffer size.Default is true.Recommend true.- Specified by:
setOptimizeMergeBuffer
in interfaceMemcachedClient
- Parameters:
optimizeMergeBuffer
-
-
isShutdown
public final boolean isShutdown()- Specified by:
isShutdown
in 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:MemcachedClient
Aadd a memcached server,the thread call this method will be blocked until the connecting operations completed(success or fail)- Specified by:
addServer
in interfaceMemcachedClient
- Parameters:
server
- host stringport
- port number- Throws:
IOException
-
addServer
add a memcached server to MemcachedClient- Specified by:
addServer
in interfaceMemcachedClient
- Parameters:
server
-port
-weight
-- Throws:
IOException
-
addServer
Description copied from interface:MemcachedClient
Add a memcached server,the thread call this method will be blocked until the connecting operations completed(success or fail)- Specified by:
addServer
in interfaceMemcachedClient
- Parameters:
inetSocketAddress
- memcached server's socket address- Throws:
IOException
-
addServer
- Specified by:
addServer
in interfaceMemcachedClient
- Throws:
IOException
-
addServer
Description copied from interface:XMemcachedClientMBean
Add memcached servers- Specified by:
addServer
in interfaceMemcachedClient
- Specified by:
addServer
in interfaceXMemcachedClientMBean
- Throws:
IOException
-
addOneServerWithWeight
Description copied from interface:XMemcachedClientMBean
Add a memcached server- Specified by:
addOneServerWithWeight
in interfaceXMemcachedClientMBean
- Parameters:
server
- a String in the form of "[host1]:[port1],[host2]:[port2]"weight
- server's weight- Throws:
IOException
-
getServersDescription
Description copied from interface:XMemcachedClientMBean
Get all connected memcached servers- Specified by:
getServersDescription
in interfaceMemcachedClient
- Specified by:
getServersDescription
in 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:XMemcachedClientMBean
Set a memcached server's weight- Specified by:
setServerWeight
in interfaceXMemcachedClientMBean
- Parameters:
server
-weight
-
-
removeServer
Description copied from interface:XMemcachedClientMBean
Remove memcached servers- Specified by:
removeServer
in interfaceMemcachedClient
- Specified by:
removeServer
in interfaceXMemcachedClientMBean
-
removeServer
Description copied from interface:MemcachedClient
Remove memcached server with the exact given address.- Specified by:
removeServer
in 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:MemcachedClient
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.- Specified by:
setOptimizeGet
in interfaceMemcachedClient
- Parameters:
optimizeGet
-
-
setBufferAllocator
Description copied from interface:MemcachedClient
Set the nio's ByteBuffer Allocator,use SimpleBufferAllocator by default.- Specified by:
setBufferAllocator
in 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:MemcachedClient
Get value by key- Specified by:
get
in 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:
TimeoutException
InterruptedException
MemcachedException
-
get
public final <T> T get(String key, long timeout) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
get
in interfaceMemcachedClient
- Throws:
TimeoutException
InterruptedException
MemcachedException
-
get
public final <T> T get(String key, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
get
in interfaceMemcachedClient
- Throws:
TimeoutException
InterruptedException
MemcachedException
-
get
public final <T> T get(String key) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
get
in interfaceMemcachedClient
- Throws:
TimeoutException
InterruptedException
MemcachedException
-
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:MemcachedClient
Just like get,But it return a GetsResponse,include cas value for cas update.- Specified by:
gets
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
key
- keytimeout
- operation timeouttranscoder
-- Returns:
- GetsResponse
- Throws:
TimeoutException
InterruptedException
MemcachedException
-
gets
public final <T> GetsResponse<T> gets(String key) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
gets
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
key
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
- See Also:
-
gets
public final <T> GetsResponse<T> gets(String key, long timeout) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
gets
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
key
-timeout
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
- See Also:
-
gets
public final <T> GetsResponse<T> gets(String key, Transcoder transcoder) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
gets
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
key
-transcoder
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
- 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:MemcachedClient
Bulk get items- Specified by:
get
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
keyCollections
- key collectiontimeout
- opTimeouttranscoder
- Value transcoder- Returns:
- Exists items map
- Throws:
TimeoutException
InterruptedException
MemcachedException
-
get
public final <T> Map<String,T> get(Collection<String> keyCollections, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
get
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
keyCollections
-transcoder
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
- See Also:
-
get
public final <T> Map<String,T> get(Collection<String> keyCollections) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
get
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
keyCollections
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
- See Also:
-
get
public final <T> Map<String,T> get(Collection<String> keyCollections, long timeout) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
get
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
keyCollections
-timeout
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
- 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:MemcachedClient
Bulk gets items- Specified by:
gets
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
keyCollections
- key collectiontimeout
- Operation timeouttranscoder
- Value transcoder- Returns:
- Exists GetsResponse map
- Throws:
TimeoutException
InterruptedException
MemcachedException
- See Also:
-
gets
public final <T> Map<String,GetsResponse<T>> gets(Collection<String> keyCollections) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
gets
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
keyCollections
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
- See Also:
-
gets
public final <T> Map<String,GetsResponse<T>> gets(Collection<String> keyCollections, long timeout) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
gets
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
keyCollections
-timeout
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
- See Also:
-
gets
public final <T> Map<String,GetsResponse<T>> gets(Collection<String> keyCollections, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
gets
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
keyCollections
-transcoder
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
- 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:MemcachedClient
Store key-value item to memcached- Specified by:
set
in 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:
TimeoutException
InterruptedException
MemcachedException
-
setWithNoReply
public void setWithNoReply(String key, int exp, Object value) throws InterruptedException, MemcachedException Description copied from interface:MemcachedClient
Store key-value item to memcached,doesn't wait for reply- Specified by:
setWithNoReply
in 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:
InterruptedException
MemcachedException
-
setWithNoReply
public <T> void setWithNoReply(String key, int exp, T value, Transcoder<T> transcoder) throws InterruptedException, MemcachedException - Specified by:
setWithNoReply
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
key
-exp
-value
-transcoder
-- Throws:
InterruptedException
MemcachedException
- See Also:
-
checkStoreArguments
-
set
public final boolean set(String key, int exp, Object value) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
set
in interfaceMemcachedClient
- Throws:
TimeoutException
InterruptedException
MemcachedException
- See Also:
-
set
public final boolean set(String key, int exp, Object value, long timeout) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
set
in interfaceMemcachedClient
- Throws:
TimeoutException
InterruptedException
MemcachedException
- See Also:
-
set
public final <T> boolean set(String key, int exp, T value, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
set
in interfaceMemcachedClient
- Throws:
TimeoutException
InterruptedException
MemcachedException
- 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:MemcachedClient
Add key-value item to memcached, success only when the key is not exists in memcached.- Specified by:
add
in 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:
TimeoutException
InterruptedException
MemcachedException
-
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:
add
in interfaceMemcachedClient
- Parameters:
key
-exp
-value
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
- See Also:
-
add
public final boolean add(String key, int exp, Object value, long timeout) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
add
in interfaceMemcachedClient
- Parameters:
key
-exp
-value
-timeout
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
- See Also:
-
add
public final <T> boolean add(String key, int exp, T value, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
add
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
key
-exp
-value
-transcoder
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
- See Also:
-
addWithNoReply
public void addWithNoReply(String key, int exp, Object value) throws InterruptedException, MemcachedException Description copied from interface:MemcachedClient
Add key-value item to memcached, success only when the key is not exists in memcached.This method doesn't wait for reply.- Specified by:
addWithNoReply
in 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:
InterruptedException
MemcachedException
-
addWithNoReply
public <T> void addWithNoReply(String key, int exp, T value, Transcoder<T> transcoder) throws InterruptedException, MemcachedException - Specified by:
addWithNoReply
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
key
-exp
-value
-transcoder
-- Throws:
InterruptedException
MemcachedException
- See Also:
-
replaceWithNoReply
public void replaceWithNoReply(String key, int exp, Object value) throws InterruptedException, MemcachedException Description copied from interface:MemcachedClient
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.- Specified by:
replaceWithNoReply
in 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:
InterruptedException
MemcachedException
-
replaceWithNoReply
public <T> void replaceWithNoReply(String key, int exp, T value, Transcoder<T> transcoder) throws InterruptedException, MemcachedException - Specified by:
replaceWithNoReply
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
key
-exp
-value
-transcoder
-- Throws:
InterruptedException
MemcachedException
- 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:MemcachedClient
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.- Specified by:
replace
in 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:
TimeoutException
InterruptedException
MemcachedException
-
replace
public final boolean replace(String key, int exp, Object value) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
replace
in interfaceMemcachedClient
- Parameters:
key
-exp
-value
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
- See Also:
-
replace
public final boolean replace(String key, int exp, Object value, long timeout) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
replace
in interfaceMemcachedClient
- Parameters:
key
-exp
-value
-timeout
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
- See Also:
-
replace
public final <T> boolean replace(String key, int exp, T value, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
replace
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
key
-exp
-value
-transcoder
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
- See Also:
-
append
public final boolean append(String key, Object value) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
append
in interfaceMemcachedClient
- Parameters:
key
-value
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
- See Also:
-
append
public final boolean append(String key, Object value, long timeout) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClient
Append value to key's data item,this method will wait for reply- Specified by:
append
in interfaceMemcachedClient
- Parameters:
key
-value
-timeout
-- Returns:
- boolean result
- Throws:
TimeoutException
InterruptedException
MemcachedException
-
appendWithNoReply
public void appendWithNoReply(String key, Object value) throws InterruptedException, MemcachedException Description copied from interface:MemcachedClient
Append value to key's data item,this method doesn't wait for reply.- Specified by:
appendWithNoReply
in interfaceMemcachedClient
- Parameters:
key
-value
-- Throws:
InterruptedException
MemcachedException
-
prepend
public final boolean prepend(String key, Object value) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
prepend
in interfaceMemcachedClient
- Parameters:
key
-value
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
- See Also:
-
prepend
public final boolean prepend(String key, Object value, long timeout) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClient
Prepend value to key's data item in memcached.This method doesn't wait for reply.- Specified by:
prepend
in interfaceMemcachedClient
- Parameters:
key
-value
-- Returns:
- boolean result
- Throws:
TimeoutException
InterruptedException
MemcachedException
-
prependWithNoReply
public void prependWithNoReply(String key, Object value) throws InterruptedException, MemcachedException Description copied from interface:MemcachedClient
Prepend value to key's data item in memcached.This method doesn't wait for reply.- Specified by:
prependWithNoReply
in interfaceMemcachedClient
- Parameters:
key
-value
-- Throws:
InterruptedException
MemcachedException
-
cas
public final boolean cas(String key, int exp, Object value, long cas) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
cas
in interfaceMemcachedClient
- Parameters:
key
-exp
-value
-cas
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
- 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:MemcachedClient
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."- Specified by:
cas
in 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:
TimeoutException
InterruptedException
MemcachedException
-
cas
public final boolean cas(String key, int exp, Object value, long timeout, long cas) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
cas
in interfaceMemcachedClient
- Parameters:
key
-exp
-value
-timeout
-cas
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
- 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:
cas
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
key
-exp
-value
-transcoder
-cas
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
- 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:MemcachedClient
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."- Specified by:
cas
in 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:
TimeoutException
InterruptedException
MemcachedException
-
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:MemcachedClient
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."- Specified by:
cas
in 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:
TimeoutException
InterruptedException
MemcachedException
-
cas
public final <T> boolean cas(String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
cas
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
key
-exp
-getsReponse
-operation
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
- See Also:
-
casWithNoReply
public <T> void casWithNoReply(String key, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
casWithNoReply
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
key
-operation
-- Throws:
TimeoutException
InterruptedException
MemcachedException
- See Also:
-
casWithNoReply
public <T> void casWithNoReply(String key, GetsResponse<T> getsResponse, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
casWithNoReply
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
key
-getsResponse
-operation
-- Throws:
TimeoutException
InterruptedException
MemcachedException
-
casWithNoReply
public <T> void casWithNoReply(String key, int exp, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
casWithNoReply
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
key
-exp
-operation
-- Throws:
TimeoutException
InterruptedException
MemcachedException
- 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:MemcachedClient
cas noreply- Specified by:
casWithNoReply
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
key
-exp
-getsReponse
-operation
-- Throws:
TimeoutException
InterruptedException
MemcachedException
-
cas
public final <T> boolean cas(String key, GetsResponse<T> getsReponse, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
cas
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
key
-getsReponse
-operation
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
- See Also:
-
cas
public final <T> boolean cas(String key, int exp, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
cas
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
key
-exp
-operation
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
- See Also:
-
cas
public final <T> boolean cas(String key, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
cas
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
key
-operation
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
- See Also:
-
delete
public final boolean delete(String key, int time) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClient
Delete 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:
delete
in interfaceMemcachedClient
- Parameters:
key
-time
-- Throws:
InterruptedException
MemcachedException
TimeoutException
-
delete
public boolean delete(String key, long opTimeout) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClient
Delete key's date item from memcached- Specified by:
delete
in interfaceMemcachedClient
- Parameters:
key
-opTimeout
- Operation timeout- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
-
delete
public boolean delete(String key, long cas, long opTimeout) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClient
Delete key's date item from memcached only if its cas value is the same as what was read.- Specified by:
delete
in interfaceMemcachedClient
- Parameters:
key
-opTimeout
- Operation timeout- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
-
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:
deleteWithNoReply
in interfaceMemcachedClient
- Parameters:
key
-time
-- Throws:
InterruptedException
MemcachedException
-
deleteWithNoReply
- Specified by:
deleteWithNoReply
in interfaceMemcachedClient
- Throws:
InterruptedException
MemcachedException
-
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:MemcachedClient
Set a new expiration time for an existing item- Specified by:
touch
in 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:
TimeoutException
InterruptedException
MemcachedException
-
touch
public boolean touch(String key, int exp) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClient
Set a new expiration time for an existing item,using default opTimeout second.- Specified by:
touch
in 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:
TimeoutException
InterruptedException
MemcachedException
-
getAndTouch
public <T> T getAndTouch(String key, int newExp, long opTimeout) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClient
Get item and set a new expiration time for it- Specified by:
getAndTouch
in 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:
TimeoutException
InterruptedException
MemcachedException
-
getAndTouch
public <T> T getAndTouch(String key, int newExp) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClient
Get item and set a new expiration time for it,using default opTimeout- Specified by:
getAndTouch
in interfaceMemcachedClient
- Type Parameters:
T
-- Parameters:
key
-newExp
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
-
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:
incr
in interfaceMemcachedClient
- Parameters:
key
-- Returns:
- the new value of the item's data, after the increment operation was carried out.
- Throws:
InterruptedException
MemcachedException
TimeoutException
-
incr
public long incr(String key, long delta, long initValue) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
incr
in interfaceMemcachedClient
- Throws:
TimeoutException
InterruptedException
MemcachedException
-
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:
incr
in interfaceMemcachedClient
- Parameters:
key
- keyinitValue
- initValue if the data is not exists.timeout
- operation timeout- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
-
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:
incr
in 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:
TimeoutException
InterruptedException
MemcachedException
-
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:
incrWithNoReply
in interfaceMemcachedClient
- Parameters:
key
-- Throws:
InterruptedException
MemcachedException
-
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:
decrWithNoReply
in interfaceMemcachedClient
- Parameters:
key
-- Throws:
InterruptedException
MemcachedException
-
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:
decr
in interfaceMemcachedClient
- Parameters:
key
-- Returns:
- the new value of the item's data, after the decrement operation was carried out.
- Throws:
InterruptedException
MemcachedException
TimeoutException
-
decr
public long decr(String key, long delta, long initValue) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
decr
in interfaceMemcachedClient
- Parameters:
key
-initValue
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
- 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:
decr
in interfaceMemcachedClient
- Parameters:
key
- The keyinitValue
- The initial value if the data is not exists.timeout
- Operation timeout- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
-
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:
decr
in 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:
TimeoutException
InterruptedException
MemcachedException
-
flushAll
Description copied from interface:MemcachedClient
Make All connected memcached's data item invalid- Specified by:
flushAll
in interfaceMemcachedClient
- Throws:
TimeoutException
InterruptedException
MemcachedException
-
flushAllWithNoReply
- Specified by:
flushAllWithNoReply
in interfaceMemcachedClient
- Throws:
InterruptedException
MemcachedException
-
flushAllWithNoReply
- Specified by:
flushAllWithNoReply
in interfaceMemcachedClient
- Throws:
InterruptedException
MemcachedException
-
flushAllWithNoReply
public void flushAllWithNoReply(InetSocketAddress address) throws MemcachedException, InterruptedException - Specified by:
flushAllWithNoReply
in interfaceMemcachedClient
- Throws:
MemcachedException
InterruptedException
-
flushAllWithNoReply
public void flushAllWithNoReply(InetSocketAddress address, int exptime) throws MemcachedException, InterruptedException - Specified by:
flushAllWithNoReply
in interfaceMemcachedClient
- Throws:
MemcachedException
InterruptedException
-
flushAll
public final void flushAll(int exptime, long timeout) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
flushAll
in interfaceMemcachedClient
- Throws:
TimeoutException
InterruptedException
MemcachedException
-
flushAll
public final void flushAll(long timeout) throws TimeoutException, InterruptedException, MemcachedException Description copied from interface:MemcachedClient
Make All connected memcached's data item invalid- Specified by:
flushAll
in interfaceMemcachedClient
- Parameters:
timeout
- operation timeout- Throws:
TimeoutException
InterruptedException
MemcachedException
-
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:MemcachedClient
Set the verbosity level of the memcached's logging output.This method will wait for reply.- Specified by:
setLoggingLevelVerbosity
in interfaceMemcachedClient
- Parameters:
address
-level
- logging level- Throws:
TimeoutException
InterruptedException
MemcachedException
-
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:MemcachedClient
Set the verbosity level of the memcached's logging output.This method doesn't wait for reply from server- Specified by:
setLoggingLevelVerbosityWithNoReply
in interfaceMemcachedClient
- Parameters:
address
- memcached server addresslevel
- logging level- Throws:
InterruptedException
MemcachedException
-
flushAll
public final void flushAll(InetSocketAddress address) throws MemcachedException, InterruptedException, TimeoutException Description copied from interface:MemcachedClient
Invalidate all existing items immediately- Specified by:
flushAll
in interfaceMemcachedClient
- Parameters:
address
- Target memcached server- Throws:
MemcachedException
InterruptedException
TimeoutException
-
flushAll
public final void flushAll(InetSocketAddress address, long timeout) throws MemcachedException, InterruptedException, TimeoutException - Specified by:
flushAll
in interfaceMemcachedClient
- Throws:
MemcachedException
InterruptedException
TimeoutException
-
flushAll
public final void flushAll(InetSocketAddress address, long timeout, int exptime) throws MemcachedException, InterruptedException, TimeoutException - Specified by:
flushAll
in interfaceMemcachedClient
- Throws:
MemcachedException
InterruptedException
TimeoutException
-
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:MemcachedClient
This method is deprecated,please use flushAll(InetSocketAddress) instead.- Specified by:
flushAll
in interfaceMemcachedClient
- Parameters:
host
-- Throws:
TimeoutException
InterruptedException
MemcachedException
-
stats
public final Map<String,String> stats(InetSocketAddress address) throws MemcachedException, InterruptedException, TimeoutException - Specified by:
stats
in interfaceMemcachedClient
- Throws:
MemcachedException
InterruptedException
TimeoutException
-
stats
public final Map<String,String> stats(InetSocketAddress address, long timeout) throws MemcachedException, InterruptedException, TimeoutException Description copied from interface:MemcachedClient
�ョ��瑰������emcached server缁��淇℃�- Specified by:
stats
in interfaceMemcachedClient
- Parameters:
address
- ����板�timeout
- ���瓒��- Returns:
- Throws:
MemcachedException
InterruptedException
TimeoutException
-
getStats
public final Map<InetSocketAddress,Map<String, getStats() throws MemcachedException, InterruptedException, TimeoutExceptionString>> - Specified by:
getStats
in interfaceMemcachedClient
- Throws:
MemcachedException
InterruptedException
TimeoutException
-
getStatsByItem
public final Map<InetSocketAddress,Map<String, getStatsByItemString>> (String itemName) throws MemcachedException, InterruptedException, TimeoutException Description copied from interface:MemcachedClient
Get special item stats. "stats items" for example- Specified by:
getStatsByItem
in interfaceMemcachedClient
- Returns:
- Throws:
MemcachedException
InterruptedException
TimeoutException
-
getStatsByItem
public final Map<InetSocketAddress,Map<String, getStatsByItemString>> (String itemName, long timeout) throws MemcachedException, InterruptedException, TimeoutException - Specified by:
getStatsByItem
in interfaceMemcachedClient
- Throws:
MemcachedException
InterruptedException
TimeoutException
-
getVersions
public final Map<InetSocketAddress,String> getVersions() throws TimeoutException, InterruptedException, MemcachedExceptionDescription copied from interface:MemcachedClient
Get all connected memcached servers's version.- Specified by:
getVersions
in interfaceMemcachedClient
- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
-
getVersions
public final Map<InetSocketAddress,String> getVersions(long timeout) throws TimeoutException, InterruptedException, MemcachedException - Specified by:
getVersions
in interfaceMemcachedClient
- Throws:
TimeoutException
InterruptedException
MemcachedException
-
getStats
public Map<InetSocketAddress,Map<String, getStatsString>> (long timeout) throws MemcachedException, InterruptedException, TimeoutException Description copied from interface:MemcachedClient
Get stats from all memcached servers- Specified by:
getStats
in interfaceMemcachedClient
- Parameters:
timeout
-- Returns:
- server->item->value map
- Throws:
MemcachedException
InterruptedException
TimeoutException
-
shutdown0
protected void shutdown0()For subclass override. -
shutdown
- Specified by:
shutdown
in 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:MemcachedClient
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. 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:
setConnectionPoolSize
in 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:
delete
in interfaceMemcachedClient
- Throws:
TimeoutException
InterruptedException
MemcachedException
-
getTranscoder
Description copied from interface:MemcachedClient
return default transcoder,default is SerializingTranscoder- Specified by:
getTranscoder
in interfaceMemcachedClient
- Returns:
-
setTranscoder
Description copied from interface:MemcachedClient
set transcoder- Specified by:
setTranscoder
in 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:
InterruptedException
TimeoutException
-
getContinuousTimeoutCounter
-
getAvaliableServers
Deprecated.Use getAvailableServers() instead- Specified by:
getAvaliableServers
in interfaceMemcachedClient
- Returns:
- See Also:
-
getAvailableServers
Description copied from interface:MemcachedClient
Returns available memcached servers list.- Specified by:
getAvailableServers
in interfaceMemcachedClient
- Returns:
- A available server collection
-
getConnectionSizeBySocketAddress
-
addStateListener
Description copied from interface:MemcachedClient
Add a memcached client listener- Specified by:
addStateListener
in interfaceMemcachedClient
- Parameters:
listener
-
-
getStateListeners
Description copied from interface:MemcachedClient
Get all current state listeners- Specified by:
getStateListeners
in interfaceMemcachedClient
- Returns:
-
setPrimitiveAsString
public void setPrimitiveAsString(boolean primitiveAsString) Description copied from interface:MemcachedClient
Store all primitive type as string,defualt is false.- Specified by:
setPrimitiveAsString
in interfaceMemcachedClient
-
removeStateListener
Description copied from interface:MemcachedClient
Remove a memcached client listener- Specified by:
removeStateListener
in interfaceMemcachedClient
- Parameters:
listener
-
-
getProtocol
- Specified by:
getProtocol
in interfaceMemcachedClient
-
isSanitizeKeys
public boolean isSanitizeKeys()- Specified by:
isSanitizeKeys
in interfaceMemcachedClient
-
setSanitizeKeys
public void setSanitizeKeys(boolean sanitizeKeys) Description copied from interface:MemcachedClient
Enables/disables sanitizing keys by URLEncoding.- Specified by:
setSanitizeKeys
in 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:MemcachedClient
Invalidate all items under the namespace.- Specified by:
invalidateNamespace
in interfaceMemcachedClient
- Parameters:
ns
- the namespaceopTimeout
- operation timeout in milliseconds.- Throws:
MemcachedException
InterruptedException
TimeoutException
-
invalidateNamespace
public void invalidateNamespace(String ns) throws MemcachedException, InterruptedException, TimeoutException Description copied from interface:MemcachedClient
Invalidate all namespace under the namespace using the default operation timeout.- Specified by:
invalidateNamespace
in interfaceMemcachedClient
- Parameters:
ns
- the namespace- Throws:
MemcachedException
InterruptedException
TimeoutException
-
getNamespace
public String getNamespace(String ns) throws TimeoutException, InterruptedException, MemcachedException Returns the real namespace of ns.- Parameters:
ns
-- Returns:
- Throws:
TimeoutException
InterruptedException
MemcachedException
-
getNSKey
-
getCounter
Description copied from interface:MemcachedClient
Get counter for key,and if the key's value is not set,then set it with initial value.- Specified by:
getCounter
in interfaceMemcachedClient
- Parameters:
key
-initialValue
-- Returns:
-
getCounter
Description copied from interface:MemcachedClient
Get counter for key,and if the key's value is not set,then set it with 0.- Specified by:
getCounter
in 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:MemcachedClient
Get 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:
getKeyIterator
in interfaceMemcachedClient
- Parameters:
address
-- Returns:
- Throws:
MemcachedException
TimeoutException
InterruptedException
-
setEnableHealSession
public void setEnableHealSession(boolean enableHealSession) Description copied from interface:MemcachedClient
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.- Specified by:
setEnableHealSession
in interfaceMemcachedClient
- Parameters:
enableHealSession
-
-
setFailureMode
public void setFailureMode(boolean failureMode) Description copied from interface:MemcachedClient
Configure 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:
setFailureMode
in interfaceMemcachedClient
- Parameters:
failureMode
- true is to configure client in failure mode.
-
isFailureMode
public boolean isFailureMode()Description copied from interface:MemcachedClient
Returns if client is in failure mode.- Specified by:
isFailureMode
in interfaceMemcachedClient
- Returns:
-
getReconnectRequestQueue
Description copied from interface:MemcachedClient
Returns reconnecting task queue,the queue is thread-safe and 'weakly consistent',but maybe you should not modify it at all.- Specified by:
getReconnectRequestQueue
in interfaceMemcachedClient
- Returns:
- The reconnecting task queue,if the client has not been started,returns null.
-