Package net.rubyeye.xmemcached
Class XMemcachedClient
- java.lang.Object
-
- net.rubyeye.xmemcached.XMemcachedClient
-
- All Implemented Interfaces:
MemcachedClient
,XMemcachedClientMBean
- Direct Known Subclasses:
AWSElasticCacheClient
public class XMemcachedClient extends java.lang.Object implements XMemcachedClientMBean, MemcachedClient
Memcached Client for connecting to memcached server and do operations.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.net.InetSocketAddress,AuthInfo>
authInfoMap
private java.util.Map<java.lang.String,AuthInfo>
authInfoStringMap
protected CommandFactory
commandFactory
protected int
connectionPoolSize
protected MemcachedConnector
connector
private long
connectTimeout
private static java.lang.String
CONTINUOUS_TIMEOUT_COUNTER
private boolean
failureMode
private boolean
isHutdownHookCalled
private KeyProvider
keyProvider
private static org.slf4j.Logger
log
protected int
maxQueuedNoReplyOperations
private MemcachedHandler
memcachedHandler
private java.lang.String
name
static java.lang.ThreadLocal<java.lang.String>
NAMESPACE_LOCAL
namespace thread local.protected long
opTimeout
protected boolean
resolveInetAddresses
private boolean
sanitizeKeys
protected java.util.concurrent.atomic.AtomicInteger
serverOrderCount
protected MemcachedSessionComparator
sessionComparator
protected MemcachedSessionLocator
sessionLocator
private boolean
shutdown
private java.lang.Thread
shutdownHookThread
private java.util.concurrent.CopyOnWriteArrayList<MemcachedClientStateListenerAdapter>
stateListenerAdapters
private int
timeoutExceptionThreshold
private Transcoder
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
Constructors Constructor Description XMemcachedClient()
XMemcachedClient(java.lang.String server, int port)
XMemcached constructor,default weight is 1XMemcachedClient(java.lang.String host, int port, int weight)
XMemcached constructorXMemcachedClient(java.net.InetSocketAddress inetSocketAddress)
XMemcachedClient(java.net.InetSocketAddress inetSocketAddress, int weight)
XMemcachedClient(java.net.InetSocketAddress inetSocketAddress, int weight, CommandFactory cmdFactory)
XMemcached Constructor.XMemcachedClient(java.util.List<java.net.InetSocketAddress> addressList)
XMemcached Constructor.Every server's weight is one by default.XMemcachedClient(java.util.List<java.net.InetSocketAddress> addressList, CommandFactory cmdFactory)
XMemcached Constructor.Every server's weight is one by default.XMemcachedClient(MemcachedSessionLocator locator, MemcachedSessionComparator comparator, BufferAllocator allocator, Configuration conf, java.util.Map<SocketOption,java.lang.Object> socketOptions, CommandFactory commandFactory, Transcoder transcoder, java.util.Map<java.net.InetSocketAddress,java.net.InetSocketAddress> addressMap, int[] weights, java.util.List<MemcachedClientStateListener> stateListeners, java.util.Map<java.net.InetSocketAddress,AuthInfo> infoMap, int poolSize, long connectTimeout, java.lang.String name, boolean failureMode, boolean resolveInetAddresses)
XMemcachedClient constructor.XMemcachedClient(MemcachedSessionLocator locator, MemcachedSessionComparator comparator, BufferAllocator allocator, Configuration conf, java.util.Map<SocketOption,java.lang.Object> socketOptions, CommandFactory commandFactory, Transcoder transcoder, java.util.Map<java.net.InetSocketAddress,java.net.InetSocketAddress> addressMap, java.util.List<MemcachedClientStateListener> stateListeners, java.util.Map<java.net.InetSocketAddress,AuthInfo> map, int poolSize, long connectTimeout, java.lang.String name, boolean failureMode, boolean resolveInetAddresses)
XMemcachedClient constructor.Every server's weight is one by default.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
add(java.lang.String key, int exp, java.lang.Object value)
boolean
add(java.lang.String key, int exp, java.lang.Object value, long timeout)
<T> boolean
add(java.lang.String key, int exp, T value, Transcoder<T> transcoder)
<T> boolean
add(java.lang.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(java.lang.String key, int exp, T value, Transcoder<T> transcoder, long timeout)
void
addOneServerWithWeight(java.lang.String server, int weight)
Add a memcached servervoid
addServer(java.lang.String hostList)
Add memcached serversvoid
addServer(java.lang.String server, int port)
Aadd a memcached server,the thread call this method will be blocked until the connecting operations completed(success or fail)void
addServer(java.lang.String server, int port, int weight)
add a memcached server to MemcachedClientvoid
addServer(java.net.InetSocketAddress inetSocketAddress)
Add a memcached server,the thread call this method will be blocked until the connecting operations completed(success or fail)void
addServer(java.net.InetSocketAddress inetSocketAddress, int weight)
void
addStateListener(MemcachedClientStateListener listener)
Add a memcached client listenervoid
addWithNoReply(java.lang.String key, int exp, java.lang.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(java.lang.String key, int exp, T value, Transcoder<T> transcoder)
boolean
append(java.lang.String key, java.lang.Object value)
boolean
append(java.lang.String key, java.lang.Object value, long timeout)
Append value to key's data item,this method will wait for replyvoid
appendWithNoReply(java.lang.String key, java.lang.Object value)
Append value to key's data item,this method doesn't wait for reply.void
beginWithNamespace(java.lang.String ns)
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, java.util.Map<SocketOption,java.lang.Object> socketOptions, CommandFactory commandFactory, Transcoder transcoder)
boolean
cas(java.lang.String key, int exp, java.lang.Object value, long cas)
boolean
cas(java.lang.String key, int exp, java.lang.Object value, long timeout, long cas)
<T> boolean
cas(java.lang.String key, int exp, CASOperation<T> operation)
<T> boolean
cas(java.lang.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."<T> boolean
cas(java.lang.String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation)
<T> boolean
cas(java.lang.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."<T> boolean
cas(java.lang.String key, int exp, T value, Transcoder<T> transcoder, long cas)
<T> boolean
cas(java.lang.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."<T> boolean
cas(java.lang.String key, CASOperation<T> operation)
<T> boolean
cas(java.lang.String key, GetsResponse<T> getsReponse, CASOperation<T> operation)
private <T> boolean
cas0(java.lang.String key, int exp, GetsResponse<T> getsResponse, CASOperation<T> operation, Transcoder<T> transcoder, byte[] keyBytes, boolean noreply)
<T> void
casWithNoReply(java.lang.String key, int exp, CASOperation<T> operation)
<T> void
casWithNoReply(java.lang.String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation)
cas noreply<T> void
casWithNoReply(java.lang.String key, CASOperation<T> operation)
<T> void
casWithNoReply(java.lang.String key, GetsResponse<T> getsResponse, CASOperation<T> operation)
private java.util.Collection<java.util.List<java.lang.String>>
catalogKeys(java.util.Collection<java.lang.String> keyCollections)
Hash key to serversprotected void
checkException(Command command)
private void
checkServerPort(java.lang.String server, int port)
private <T> byte[]
checkStoreArguments(java.lang.String key, int exp, T value)
protected void
connect(InetSocketAddressWrapper inetSocketAddressWrapper)
private java.lang.String
decodeKey(java.lang.String key)
long
decr(java.lang.String key, long delta)
"decr" are used to change data for some item in-place, decrementing it.long
decr(java.lang.String key, long delta, long initValue)
long
decr(java.lang.String key, long delta, long initValue, long timeout)
"decr" are used to change data for some item in-place, decrementing it.long
decr(java.lang.String key, long delta, long initValue, long timeout, int exp)
"incr" are used to change data for some item in-place, incrementing it.void
decrWithNoReply(java.lang.String key, long delta)
"decr" are used to change data for some item in-place, decrementing it.boolean
delete(java.lang.String key)
boolean
delete(java.lang.String key, int time)
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(java.lang.String key, long opTimeout)
Delete key's date item from memcachedboolean
delete(java.lang.String key, long cas, long opTimeout)
Delete key's date item from memcached only if its cas value is the same as what was read.private boolean
delete0(java.lang.String key, int time, long cas, boolean noreply, long opTimeout)
void
deleteWithNoReply(java.lang.String key)
void
deleteWithNoReply(java.lang.String key, int time)
Delete key's data item from memcached.This method doesn't wait for replyvoid
endWithNamespace()
Remove current namespace set for this memcached client.It must begin withMemcachedClient.beginWithNamespace(String)
method.private <T> java.lang.Object
fetch0(java.lang.String key, byte[] keyBytes, CommandType cmdType, long timeout, Transcoder<T> transcoder)
void
flushAll()
Make All connected memcached's data item invalidvoid
flushAll(int exptime, long timeout)
void
flushAll(long timeout)
Make All connected memcached's data item invalidvoid
flushAll(java.lang.String host)
This method is deprecated,please use flushAll(InetSocketAddress) instead.void
flushAll(java.net.InetSocketAddress address)
Invalidate all existing items immediatelyvoid
flushAll(java.net.InetSocketAddress address, long timeout)
void
flushAll(java.net.InetSocketAddress address, long timeout, int exptime)
private void
flushAllMemcachedServers(long timeout, boolean noreply, int exptime)
void
flushAllWithNoReply()
void
flushAllWithNoReply(int exptime)
void
flushAllWithNoReply(java.net.InetSocketAddress address)
void
flushAllWithNoReply(java.net.InetSocketAddress address, int exptime)
private void
flushSpecialMemcachedServer(java.net.InetSocketAddress address, long timeout, boolean noreply, int exptime)
<T> T
get(java.lang.String key)
<T> T
get(java.lang.String key, long timeout)
<T> T
get(java.lang.String key, long timeout, Transcoder<T> transcoder)
Get value by key<T> T
get(java.lang.String key, Transcoder<T> transcoder)
<T> java.util.Map<java.lang.String,T>
get(java.util.Collection<java.lang.String> keyCollections)
<T> java.util.Map<java.lang.String,T>
get(java.util.Collection<java.lang.String> keyCollections, long timeout)
<T> java.util.Map<java.lang.String,T>
get(java.util.Collection<java.lang.String> keyCollections, long timeout, Transcoder<T> transcoder)
Bulk get items<T> java.util.Map<java.lang.String,T>
get(java.util.Collection<java.lang.String> keyCollections, Transcoder<T> transcoder)
private <T> java.lang.Object
get0(java.lang.String key, long timeout, CommandType cmdType, Transcoder<T> transcoder)
<T> T
getAndTouch(java.lang.String key, int newExp)
Get item and set a new expiration time for it,using default opTimeout<T> T
getAndTouch(java.lang.String key, int newExp, long opTimeout)
Get item and set a new expiration time for itjava.util.Map<java.net.InetSocketAddress,AuthInfo>
getAuthInfoMap()
return current all auth infojava.util.Map<java.lang.String,AuthInfo>
getAuthInfoStringMap()
Retruns the AuthInfo for all server strings (hostname:port)java.util.Collection<java.net.InetSocketAddress>
getAvailableServers()
Returns available memcached servers list.java.util.Collection<java.net.InetSocketAddress>
getAvaliableServers()
Deprecated.CommandFactory
getCommandFactory()
int
getConnectionSizeBySocketAddress(java.net.InetSocketAddress address)
Connector
getConnector()
return the session managerlong
getConnectTimeout()
Get the connect timeoutprivate java.util.concurrent.atomic.AtomicInteger
getContinuousTimeoutCounter(Session session)
Counter
getCounter(java.lang.String key)
Get counter for key,and if the key's value is not set,then set it with 0.Counter
getCounter(java.lang.String key, long initialValue)
Get counter for key,and if the key's value is not set,then set it with initial value.long
getHealSessionInterval()
Return the default heal session interval in millisecondsKeyIterator
getKeyIterator(java.net.InetSocketAddress address)
Deprecated.memcached 1.6.x will remove cachedump stats command,so this method will be removed in the futureKeyProvider
getKeyProvider()
private <T> java.util.Map<java.lang.String,T>
getMulti0(java.util.Collection<java.lang.String> keys, long timeout, CommandType cmdType, Transcoder<T> transcoder)
java.lang.String
getName()
Return the cache instance namejava.lang.String
getNamespace(java.lang.String ns)
Returns the real namespace of ns.private java.lang.String
getNSKey(java.lang.String ns)
long
getOpTimeout()
get operation timeout settingProtocol
getProtocol()
java.util.Queue<ReconnectRequest>
getReconnectRequestQueue()
Returns reconnecting task queue,the queue is thread-safe and 'weakly consistent',but maybe you should not modify it at all.<T> GetsResponse<T>
gets(java.lang.String key)
<T> GetsResponse<T>
gets(java.lang.String key, long timeout)
<T> GetsResponse<T>
gets(java.lang.String key, long timeout, Transcoder<T> transcoder)
Just like get,But it return a GetsResponse,include cas value for cas update.<T> GetsResponse<T>
gets(java.lang.String key, Transcoder transcoder)
<T> java.util.Map<java.lang.String,GetsResponse<T>>
gets(java.util.Collection<java.lang.String> keyCollections)
<T> java.util.Map<java.lang.String,GetsResponse<T>>
gets(java.util.Collection<java.lang.String> keyCollections, long timeout)
<T> java.util.Map<java.lang.String,GetsResponse<T>>
gets(java.util.Collection<java.lang.String> keyCollections, long timeout, Transcoder<T> transcoder)
Bulk gets items<T> java.util.Map<java.lang.String,GetsResponse<T>>
gets(java.util.Collection<java.lang.String> keyCollections, Transcoder<T> transcoder)
private <T> GetsResponse<T>
gets0(java.lang.String key, byte[] keyBytes, Transcoder<T> transcoder)
java.util.List<java.lang.String>
getServersDescription()
Get all connected memcached serversMemcachedSessionComparator
getSessionComparator()
MemcachedSessionLocator
getSessionLocator()
java.util.Collection<MemcachedClientStateListener>
getStateListeners()
Get all current state listenersjava.util.Map<java.net.InetSocketAddress,java.util.Map<java.lang.String,java.lang.String>>
getStats()
java.util.Map<java.net.InetSocketAddress,java.util.Map<java.lang.String,java.lang.String>>
getStats(long timeout)
Get stats from all memcached serversjava.util.Map<java.net.InetSocketAddress,java.util.Map<java.lang.String,java.lang.String>>
getStatsByItem(java.lang.String itemName)
Get special item stats.java.util.Map<java.net.InetSocketAddress,java.util.Map<java.lang.String,java.lang.String>>
getStatsByItem(java.lang.String itemName, long timeout)
int
getTimeoutExceptionThreshold()
Returns maximum number of timeout exception for closing connection.Transcoder
getTranscoder()
return default transcoder,default is SerializingTranscoderjava.util.Map<java.net.InetSocketAddress,java.lang.String>
getVersions()
Get all connected memcached servers's version.java.util.Map<java.net.InetSocketAddress,java.lang.String>
getVersions(long timeout)
long
incr(java.lang.String key, long delta)
"incr" are used to change data for some item in-place, incrementing it.long
incr(java.lang.String key, long delta, long initValue)
long
incr(java.lang.String key, long delta, long initValue, long timeout)
"incr" are used to change data for some item in-place, incrementing it.long
incr(java.lang.String key, long delta, long initValue, long timeout, int exp)
"incr" are used to change data for some item in-place, incrementing it.void
incrWithNoReply(java.lang.String key, long delta)
"incr" are used to change data for some item in-place, incrementing it.void
invalidateNamespace(java.lang.String ns)
Invalidate all namespace under the namespace using the default operation timeout.void
invalidateNamespace(java.lang.String ns, long opTimeout)
Invalidate all items under the namespace.boolean
isFailureMode()
Returns if client is in failure mode.boolean
isSanitizeKeys()
boolean
isShutdown()
private boolean
isWindowsPlatform()
protected void
latchWait(Command cmd, long timeout, Session session)
protected MemcachedConnector
newConnector(BufferAllocator bufferAllocator, Configuration configuration, MemcachedSessionLocator memcachedSessionLocator, MemcachedSessionComparator memcachedSessionComparator, CommandFactory commandFactory, int poolSize, int maxQueuedNoReplyOperations)
protected java.net.InetSocketAddress
newSocketAddress(java.lang.String server, int port)
private void
optimiezeSetReadThreadCount(Configuration conf, int addressCount)
boolean
prepend(java.lang.String key, java.lang.Object value)
boolean
prepend(java.lang.String key, java.lang.Object value, long timeout)
Prepend value to key's data item in memcached.This method doesn't wait for reply.void
prependWithNoReply(java.lang.String key, java.lang.Object value)
Prepend value to key's data item in memcached.This method doesn't wait for reply.private java.lang.String
preProcessKey(java.lang.String key)
private <T> java.util.Map<java.lang.String,T>
reduceResult(CommandType cmdType, Transcoder<T> transcoder, java.util.List<Command> commands)
private void
registerMBean()
void
removeServer(java.lang.String hostList)
Remove memcached serversvoid
removeServer(java.net.InetSocketAddress address)
Remove memcached server with the exact given address.void
removeStateListener(MemcachedClientStateListener listener)
Remove a memcached client listenerboolean
replace(java.lang.String key, int exp, java.lang.Object value)
boolean
replace(java.lang.String key, int exp, java.lang.Object value, long timeout)
<T> boolean
replace(java.lang.String key, int exp, T value, Transcoder<T> transcoder)
<T> boolean
replace(java.lang.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(java.lang.String key, int exp, java.lang.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(java.lang.String key, int exp, T value, Transcoder<T> transcoder)
protected Session
sendCommand(Command cmd)
private <T> Command
sendGetMultiCommand(java.util.Collection<java.lang.String> keys, java.util.concurrent.CountDownLatch latch, CommandType cmdType, Transcoder<T> transcoder)
private long
sendIncrOrDecrCommand(java.lang.String key, long delta, long initValue, CommandType cmdType, boolean noreply, long operationTimeout, int exp)
private <T> boolean
sendStoreCommand(Command command, long timeout)
boolean
set(java.lang.String key, int exp, java.lang.Object value)
boolean
set(java.lang.String key, int exp, java.lang.Object value, long timeout)
<T> boolean
set(java.lang.String key, int exp, T value, Transcoder<T> transcoder)
<T> boolean
set(java.lang.String key, int exp, T value, Transcoder<T> transcoder, long timeout)
Store key-value item to memcachedvoid
setAuthInfoMap(java.util.Map<java.net.InetSocketAddress,AuthInfo> map)
Configure auth infovoid
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(java.net.InetSocketAddress address, int level)
Set the verbosity level of the memcached's logging output.This method will wait for reply.void
setLoggingLevelVerbosityWithNoReply(java.net.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(java.net.InetSocketAddress address, int level, boolean noreply)
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
setName(java.lang.String name)
Set cache instance namevoid
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.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.void
setServerWeight(java.lang.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.void
setTranscoder(Transcoder transcoder)
set transcodervoid
setWithNoReply(java.lang.String key, int exp, java.lang.Object value)
Store key-value item to memcached,doesn't wait for reply<T> void
setWithNoReply(java.lang.String key, int exp, T value, Transcoder<T> transcoder)
void
shutdown()
protected void
shutdown0()
For subclass override.private void
start0()
private void
startConnector()
java.util.Map<java.lang.String,java.lang.String>
stats(java.net.InetSocketAddress address)
java.util.Map<java.lang.String,java.lang.String>
stats(java.net.InetSocketAddress address, long timeout)
�ョ��瑰������emcached server缁��淇℃�boolean
touch(java.lang.String key, int exp)
Set a new expiration time for an existing item,using default opTimeout second.boolean
touch(java.lang.String key, int exp, long opTimeout)
Set a new expiration time for an existing item<T> T
withNamespace(java.lang.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 Detail
-
log
private static final org.slf4j.Logger log
-
sessionLocator
protected MemcachedSessionLocator sessionLocator
-
sessionComparator
protected MemcachedSessionComparator sessionComparator
-
shutdown
private volatile boolean shutdown
-
connector
protected MemcachedConnector connector
-
transcoder
private Transcoder transcoder
-
sanitizeKeys
private boolean sanitizeKeys
-
memcachedHandler
private MemcachedHandler memcachedHandler
-
commandFactory
protected CommandFactory commandFactory
-
opTimeout
protected long opTimeout
-
connectTimeout
private long connectTimeout
-
connectionPoolSize
protected int connectionPoolSize
-
maxQueuedNoReplyOperations
protected int maxQueuedNoReplyOperations
-
resolveInetAddresses
protected boolean resolveInetAddresses
-
serverOrderCount
protected final java.util.concurrent.atomic.AtomicInteger serverOrderCount
-
authInfoMap
private java.util.Map<java.net.InetSocketAddress,AuthInfo> authInfoMap
-
authInfoStringMap
private java.util.Map<java.lang.String,AuthInfo> authInfoStringMap
-
name
private java.lang.String name
-
failureMode
private boolean failureMode
-
timeoutExceptionThreshold
private int timeoutExceptionThreshold
-
stateListenerAdapters
private final java.util.concurrent.CopyOnWriteArrayList<MemcachedClientStateListenerAdapter> stateListenerAdapters
-
shutdownHookThread
private java.lang.Thread shutdownHookThread
-
isHutdownHookCalled
private volatile boolean isHutdownHookCalled
-
keyProvider
private KeyProvider keyProvider
-
NAMESPACE_LOCAL
public static final java.lang.ThreadLocal<java.lang.String> NAMESPACE_LOCAL
namespace thread local.
-
CONTINUOUS_TIMEOUT_COUNTER
private static final java.lang.String CONTINUOUS_TIMEOUT_COUNTER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
XMemcachedClient
public XMemcachedClient(java.lang.String server, int port) throws java.io.IOException
XMemcached constructor,default weight is 1- Parameters:
server
- �����Pport
- ����ㄧ���- Throws:
java.io.IOException
-
XMemcachedClient
public XMemcachedClient(java.lang.String host, int port, int weight) throws java.io.IOException
XMemcached constructor- Parameters:
host
- server hostport
- server portweight
- server weight- Throws:
java.io.IOException
-
XMemcachedClient
public XMemcachedClient(java.net.InetSocketAddress inetSocketAddress, int weight, CommandFactory cmdFactory) throws java.io.IOException
XMemcached Constructor.- Parameters:
inetSocketAddress
-weight
-- Throws:
java.io.IOException
-
XMemcachedClient
public XMemcachedClient(java.net.InetSocketAddress inetSocketAddress, int weight) throws java.io.IOException
- Throws:
java.io.IOException
-
XMemcachedClient
public XMemcachedClient(java.net.InetSocketAddress inetSocketAddress) throws java.io.IOException
- Throws:
java.io.IOException
-
XMemcachedClient
public XMemcachedClient() throws java.io.IOException
- Throws:
java.io.IOException
-
XMemcachedClient
public XMemcachedClient(MemcachedSessionLocator locator, MemcachedSessionComparator comparator, BufferAllocator allocator, Configuration conf, java.util.Map<SocketOption,java.lang.Object> socketOptions, CommandFactory commandFactory, Transcoder transcoder, java.util.Map<java.net.InetSocketAddress,java.net.InetSocketAddress> addressMap, java.util.List<MemcachedClientStateListener> stateListeners, java.util.Map<java.net.InetSocketAddress,AuthInfo> map, int poolSize, long connectTimeout, java.lang.String name, boolean failureMode, boolean resolveInetAddresses) throws java.io.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
-addressList
-stateListeners
-- Throws:
java.io.IOException
-
XMemcachedClient
XMemcachedClient(MemcachedSessionLocator locator, MemcachedSessionComparator comparator, BufferAllocator allocator, Configuration conf, java.util.Map<SocketOption,java.lang.Object> socketOptions, CommandFactory commandFactory, Transcoder transcoder, java.util.Map<java.net.InetSocketAddress,java.net.InetSocketAddress> addressMap, int[] weights, java.util.List<MemcachedClientStateListener> stateListeners, java.util.Map<java.net.InetSocketAddress,AuthInfo> infoMap, int poolSize, long connectTimeout, java.lang.String name, boolean failureMode, boolean resolveInetAddresses) throws java.io.IOException
XMemcachedClient constructor.- Parameters:
locator
-comparator
-allocator
-conf
-commandFactory
-transcoder
-addressList
-weights
-stateListeners
- weight array for address list- Throws:
java.io.IOException
-
XMemcachedClient
public XMemcachedClient(java.util.List<java.net.InetSocketAddress> addressList) throws java.io.IOException
XMemcached Constructor.Every server's weight is one by default.- Parameters:
addressList
-- Throws:
java.io.IOException
-
XMemcachedClient
public XMemcachedClient(java.util.List<java.net.InetSocketAddress> addressList, CommandFactory cmdFactory) throws java.io.IOException
XMemcached Constructor.Every server's weight is one by default.- Parameters:
cmdFactory
- command factoryaddressList
- memcached server socket address list.- Throws:
java.io.IOException
-
-
Method Detail
-
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
-
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
- See Also:
MemcachedClient.DEFAULT_MAX_TIMEOUTEXCEPTION_THRESHOLD
-
withNamespace
public <T> T withNamespace(java.lang.String ns, MemcachedClientCallable<T> callable) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.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
- Returns:
- Throws:
MemcachedException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
- See Also:
MemcachedClient.beginWithNamespace(String)
,MemcachedClient.endWithNamespace()
-
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:
MemcachedClient.beginWithNamespace(String)
-
beginWithNamespace
public void beginWithNamespace(java.lang.String ns)
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
- See Also:
MemcachedClient.endWithNamespace()
,MemcachedClient.withNamespace(String, MemcachedClientCallable)
-
getKeyProvider
public KeyProvider getKeyProvider()
-
setKeyProvider
public void setKeyProvider(KeyProvider keyProvider)
Description copied from interface:MemcachedClient
Set a key provider for pre-processing keys before sending them to memcached.- Specified by:
setKeyProvider
in interfaceMemcachedClient
-
getSessionLocator
public final MemcachedSessionLocator getSessionLocator()
-
getSessionComparator
public final MemcachedSessionComparator getSessionComparator()
-
getCommandFactory
public final CommandFactory getCommandFactory()
-
getName
public java.lang.String getName()
Description copied from interface:XMemcachedClientMBean
Return the cache instance name- Specified by:
getName
in interfaceMemcachedClient
- Specified by:
getName
in interfaceXMemcachedClientMBean
- Returns:
-
setName
public void setName(java.lang.String name)
Description copied from interface:MemcachedClient
Set cache instance name- Specified by:
setName
in interfaceMemcachedClient
-
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
-
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
public java.util.Map<java.net.InetSocketAddress,AuthInfo> 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
public void setAuthInfoMap(java.util.Map<java.net.InetSocketAddress,AuthInfo> map)
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
public java.util.Map<java.lang.String,AuthInfo> 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
public final Connector 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
-
isShutdown
public final boolean isShutdown()
- Specified by:
isShutdown
in interfaceMemcachedClient
- Returns:
-
gets0
private final <T> GetsResponse<T> gets0(java.lang.String key, byte[] keyBytes, Transcoder<T> transcoder) throws MemcachedException, java.util.concurrent.TimeoutException, java.lang.InterruptedException
- Throws:
MemcachedException
java.util.concurrent.TimeoutException
java.lang.InterruptedException
-
sendCommand
protected final Session sendCommand(Command cmd) throws MemcachedException
- Throws:
MemcachedException
-
newSocketAddress
protected java.net.InetSocketAddress newSocketAddress(java.lang.String server, int port)
-
checkServerPort
private void checkServerPort(java.lang.String server, int port)
-
addServer
public final void addServer(java.lang.String server, int port) throws java.io.IOException
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:
java.io.IOException
-
addServer
public final void addServer(java.lang.String server, int port, int weight) throws java.io.IOException
add a memcached server to MemcachedClient- Specified by:
addServer
in interfaceMemcachedClient
- Parameters:
server
-port
-weight
-- Throws:
java.io.IOException
-
addServer
public final void addServer(java.net.InetSocketAddress inetSocketAddress) throws java.io.IOException
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:
java.io.IOException
-
addServer
public final void addServer(java.net.InetSocketAddress inetSocketAddress, int weight) throws java.io.IOException
- Specified by:
addServer
in interfaceMemcachedClient
- Throws:
java.io.IOException
-
addServer
public final void addServer(java.lang.String hostList) throws java.io.IOException
Description copied from interface:XMemcachedClientMBean
Add memcached servers- Specified by:
addServer
in interfaceMemcachedClient
- Specified by:
addServer
in interfaceXMemcachedClientMBean
- Throws:
java.io.IOException
-
addOneServerWithWeight
public void addOneServerWithWeight(java.lang.String server, int weight) throws java.io.IOException
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:
java.io.IOException
-
getServersDescription
public final java.util.List<java.lang.String> 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
public final void setServerWeight(java.lang.String server, int weight)
Description copied from interface:XMemcachedClientMBean
Set a memcached server's weight- Specified by:
setServerWeight
in interfaceXMemcachedClientMBean
-
removeServer
public final void removeServer(java.lang.String hostList)
Description copied from interface:XMemcachedClientMBean
Remove memcached servers- Specified by:
removeServer
in interfaceMemcachedClient
- Specified by:
removeServer
in interfaceXMemcachedClientMBean
-
removeServer
public void removeServer(java.net.InetSocketAddress address)
Description copied from interface:MemcachedClient
Remove memcached server with the exact given address.- Specified by:
removeServer
in interfaceMemcachedClient
- Parameters:
address
- Resolved server address
-
connect
protected void connect(InetSocketAddressWrapper inetSocketAddressWrapper) throws java.io.IOException
- Throws:
java.io.IOException
-
fetch0
private final <T> java.lang.Object fetch0(java.lang.String key, byte[] keyBytes, CommandType cmdType, long timeout, Transcoder<T> transcoder) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException, MemcachedException
- Throws:
java.lang.InterruptedException
java.util.concurrent.TimeoutException
MemcachedException
-
start0
private final void start0() throws java.io.IOException
- Throws:
java.io.IOException
-
startConnector
private final void startConnector() throws java.io.IOException
- Throws:
java.io.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, java.util.Map<SocketOption,java.lang.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
-
setBufferAllocator
public final void setBufferAllocator(BufferAllocator bufferAllocator)
Description copied from interface:MemcachedClient
Set the nio's ByteBuffer Allocator,use SimpleBufferAllocator by default.- Specified by:
setBufferAllocator
in interfaceMemcachedClient
-
optimiezeSetReadThreadCount
private final void optimiezeSetReadThreadCount(Configuration conf, int addressCount)
-
isWindowsPlatform
private final boolean isWindowsPlatform()
-
get
public final <T> T get(java.lang.String key, long timeout, Transcoder<T> transcoder) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
Description copied from interface:MemcachedClient
Get value by key- Specified by:
get
in interfaceMemcachedClient
- Parameters:
key
- Keytimeout
- Operation timeout,if the method is not returned in this time,throw TimeoutExceptiontranscoder
- The value's transcoder- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
get
public final <T> T get(java.lang.String key, long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
get
in interfaceMemcachedClient
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
get
public final <T> T get(java.lang.String key, Transcoder<T> transcoder) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
get
in interfaceMemcachedClient
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
get
public final <T> T get(java.lang.String key) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
get
in interfaceMemcachedClient
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
get0
private <T> java.lang.Object get0(java.lang.String key, long timeout, CommandType cmdType, Transcoder<T> transcoder) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
gets
public final <T> GetsResponse<T> gets(java.lang.String key, long timeout, Transcoder<T> transcoder) throws java.util.concurrent.TimeoutException, java.lang.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
- Parameters:
key
- keytimeout
- operation timeout- Returns:
- GetsResponse
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
gets
public final <T> GetsResponse<T> gets(java.lang.String key) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
gets
in interfaceMemcachedClient
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.gets(String, long, Transcoder)
-
gets
public final <T> GetsResponse<T> gets(java.lang.String key, long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
gets
in interfaceMemcachedClient
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.gets(String, long, Transcoder)
-
gets
public final <T> GetsResponse<T> gets(java.lang.String key, Transcoder transcoder) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
gets
in interfaceMemcachedClient
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.gets(String, long, Transcoder)
-
get
public final <T> java.util.Map<java.lang.String,T> get(java.util.Collection<java.lang.String> keyCollections, long timeout, Transcoder<T> transcoder) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
Description copied from interface:MemcachedClient
Bulk get items- Specified by:
get
in interfaceMemcachedClient
- Parameters:
keyCollections
- key collectiontimeout
- opTimeouttranscoder
- Value transcoder- Returns:
- Exists items map
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
get
public final <T> java.util.Map<java.lang.String,T> get(java.util.Collection<java.lang.String> keyCollections, Transcoder<T> transcoder) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
get
in interfaceMemcachedClient
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.get(Collection, long, Transcoder)
-
get
public final <T> java.util.Map<java.lang.String,T> get(java.util.Collection<java.lang.String> keyCollections) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
get
in interfaceMemcachedClient
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.get(Collection, long, Transcoder)
-
get
public final <T> java.util.Map<java.lang.String,T> get(java.util.Collection<java.lang.String> keyCollections, long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
get
in interfaceMemcachedClient
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.get(Collection, long, Transcoder)
-
gets
public final <T> java.util.Map<java.lang.String,GetsResponse<T>> gets(java.util.Collection<java.lang.String> keyCollections, long timeout, Transcoder<T> transcoder) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
Description copied from interface:MemcachedClient
Bulk gets items- Specified by:
gets
in interfaceMemcachedClient
- Parameters:
keyCollections
- key collectiontimeout
- Operation timeouttranscoder
- Value transcoder- Returns:
- Exists GetsResponse map
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
GetsResponse
-
gets
public final <T> java.util.Map<java.lang.String,GetsResponse<T>> gets(java.util.Collection<java.lang.String> keyCollections) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
gets
in interfaceMemcachedClient
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.gets(Collection, long, Transcoder)
-
gets
public final <T> java.util.Map<java.lang.String,GetsResponse<T>> gets(java.util.Collection<java.lang.String> keyCollections, long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
gets
in interfaceMemcachedClient
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.gets(Collection, long, Transcoder)
-
gets
public final <T> java.util.Map<java.lang.String,GetsResponse<T>> gets(java.util.Collection<java.lang.String> keyCollections, Transcoder<T> transcoder) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
gets
in interfaceMemcachedClient
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.gets(Collection, long, Transcoder)
-
getMulti0
private final <T> java.util.Map<java.lang.String,T> getMulti0(java.util.Collection<java.lang.String> keys, long timeout, CommandType cmdType, Transcoder<T> transcoder) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
reduceResult
private <T> java.util.Map<java.lang.String,T> reduceResult(CommandType cmdType, Transcoder<T> transcoder, java.util.List<Command> commands) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
- Throws:
MemcachedException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
-
catalogKeys
private final java.util.Collection<java.util.List<java.lang.String>> catalogKeys(java.util.Collection<java.lang.String> keyCollections)
Hash key to servers- Parameters:
keyCollections
-- Returns:
-
sendGetMultiCommand
private final <T> Command sendGetMultiCommand(java.util.Collection<java.lang.String> keys, java.util.concurrent.CountDownLatch latch, CommandType cmdType, Transcoder<T> transcoder) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException, MemcachedException
- Throws:
java.lang.InterruptedException
java.util.concurrent.TimeoutException
MemcachedException
-
set
public final <T> boolean set(java.lang.String key, int exp, T value, Transcoder<T> transcoder, long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
Description copied from interface:MemcachedClient
Store key-value item to memcached- Specified by:
set
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 datatranscoder
- transocdertimeout
- operation timeout,in milliseconds- Returns:
- boolean result
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
setWithNoReply
public void setWithNoReply(java.lang.String key, int exp, java.lang.Object value) throws java.lang.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:
java.lang.InterruptedException
MemcachedException
-
setWithNoReply
public <T> void setWithNoReply(java.lang.String key, int exp, T value, Transcoder<T> transcoder) throws java.lang.InterruptedException, MemcachedException
- Specified by:
setWithNoReply
in interfaceMemcachedClient
- Throws:
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.setWithNoReply(String, int, Object, Transcoder)
-
checkStoreArguments
private final <T> byte[] checkStoreArguments(java.lang.String key, int exp, T value)
-
set
public final boolean set(java.lang.String key, int exp, java.lang.Object value) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
set
in interfaceMemcachedClient
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.set(String, int, Object, Transcoder, long)
-
set
public final boolean set(java.lang.String key, int exp, java.lang.Object value, long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
set
in interfaceMemcachedClient
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.set(String, int, Object, Transcoder, long)
-
set
public final <T> boolean set(java.lang.String key, int exp, T value, Transcoder<T> transcoder) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
set
in interfaceMemcachedClient
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.set(String, int, Object, Transcoder, long)
-
add
public final <T> boolean add(java.lang.String key, int exp, T value, Transcoder<T> transcoder, long timeout) throws java.util.concurrent.TimeoutException, java.lang.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
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.- Returns:
- boolean result
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
add0
private <T> boolean add0(java.lang.String key, int exp, T value, Transcoder<T> transcoder, long timeout) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException, MemcachedException
- Throws:
java.lang.InterruptedException
java.util.concurrent.TimeoutException
MemcachedException
-
add
public final boolean add(java.lang.String key, int exp, java.lang.Object value) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
add
in interfaceMemcachedClient
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.add(String, int, Object, Transcoder, long)
-
add
public final boolean add(java.lang.String key, int exp, java.lang.Object value, long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
add
in interfaceMemcachedClient
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.add(String, int, Object, Transcoder, long)
-
add
public final <T> boolean add(java.lang.String key, int exp, T value, Transcoder<T> transcoder) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
add
in interfaceMemcachedClient
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.add(String, int, Object, Transcoder, long)
-
addWithNoReply
public void addWithNoReply(java.lang.String key, int exp, java.lang.Object value) throws java.lang.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
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.- Throws:
java.lang.InterruptedException
MemcachedException
-
addWithNoReply
public <T> void addWithNoReply(java.lang.String key, int exp, T value, Transcoder<T> transcoder) throws java.lang.InterruptedException, MemcachedException
- Specified by:
addWithNoReply
in interfaceMemcachedClient
- Throws:
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.addWithNoReply(String, int, Object, Transcoder)
-
replaceWithNoReply
public void replaceWithNoReply(java.lang.String key, int exp, java.lang.Object value) throws java.lang.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
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.- Throws:
java.lang.InterruptedException
MemcachedException
-
replaceWithNoReply
public <T> void replaceWithNoReply(java.lang.String key, int exp, T value, Transcoder<T> transcoder) throws java.lang.InterruptedException, MemcachedException
- Specified by:
replaceWithNoReply
in interfaceMemcachedClient
- Throws:
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.replaceWithNoReply(String, int, Object, Transcoder)
-
replace
public final <T> boolean replace(java.lang.String key, int exp, T value, Transcoder<T> transcoder, long timeout) throws java.util.concurrent.TimeoutException, java.lang.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
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.- Returns:
- boolean result
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
replace
public final boolean replace(java.lang.String key, int exp, java.lang.Object value) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
replace
in interfaceMemcachedClient
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.replace(String, int, Object, Transcoder, long)
-
replace
public final boolean replace(java.lang.String key, int exp, java.lang.Object value, long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
replace
in interfaceMemcachedClient
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.replace(String, int, Object, Transcoder, long)
-
replace
public final <T> boolean replace(java.lang.String key, int exp, T value, Transcoder<T> transcoder) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
replace
in interfaceMemcachedClient
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.replace(String, int, Object, Transcoder, long)
-
append
public final boolean append(java.lang.String key, java.lang.Object value) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
append
in interfaceMemcachedClient
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.append(String, Object, long)
-
append
public final boolean append(java.lang.String key, java.lang.Object value, long timeout) throws java.util.concurrent.TimeoutException, java.lang.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
- Returns:
- boolean result
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
appendWithNoReply
public void appendWithNoReply(java.lang.String key, java.lang.Object value) throws java.lang.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
- Throws:
java.lang.InterruptedException
MemcachedException
-
prepend
public final boolean prepend(java.lang.String key, java.lang.Object value) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
prepend
in interfaceMemcachedClient
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.prepend(String, Object, long)
-
prepend
public final boolean prepend(java.lang.String key, java.lang.Object value, long timeout) throws java.util.concurrent.TimeoutException, java.lang.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
- Returns:
- boolean result
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
prependWithNoReply
public void prependWithNoReply(java.lang.String key, java.lang.Object value) throws java.lang.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
- Throws:
java.lang.InterruptedException
MemcachedException
-
cas
public final boolean cas(java.lang.String key, int exp, java.lang.Object value, long cas) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
cas
in interfaceMemcachedClient
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.cas(String, int, Object, Transcoder, long, long)
-
cas
public final <T> boolean cas(java.lang.String key, int exp, T value, Transcoder<T> transcoder, long timeout, long cas) throws java.util.concurrent.TimeoutException, java.lang.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
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.- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
cas
public final boolean cas(java.lang.String key, int exp, java.lang.Object value, long timeout, long cas) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
cas
in interfaceMemcachedClient
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.cas(String, int, Object, Transcoder, long, long)
-
cas
public final <T> boolean cas(java.lang.String key, int exp, T value, Transcoder<T> transcoder, long cas) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
cas
in interfaceMemcachedClient
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.cas(String, int, Object, Transcoder, long, long)
-
cas0
private final <T> boolean cas0(java.lang.String key, int exp, GetsResponse<T> getsResponse, CASOperation<T> operation, Transcoder<T> transcoder, byte[] keyBytes, boolean noreply) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
cas
public final <T> boolean cas(java.lang.String key, int exp, CASOperation<T> operation, Transcoder<T> transcoder) throws java.util.concurrent.TimeoutException, java.lang.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
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:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
cas
public final <T> boolean cas(java.lang.String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation, Transcoder<T> transcoder) throws java.util.concurrent.TimeoutException, java.lang.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
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
- CASOperation- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
cas
public final <T> boolean cas(java.lang.String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
cas
in interfaceMemcachedClient
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.cas(String, int, GetsResponse, CASOperation, Transcoder)
-
casWithNoReply
public <T> void casWithNoReply(java.lang.String key, CASOperation<T> operation) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
casWithNoReply
in interfaceMemcachedClient
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.casWithNoReply(String, int, GetsResponse, CASOperation)
-
casWithNoReply
public <T> void casWithNoReply(java.lang.String key, GetsResponse<T> getsResponse, CASOperation<T> operation) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
casWithNoReply
in interfaceMemcachedClient
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
casWithNoReply
public <T> void casWithNoReply(java.lang.String key, int exp, CASOperation<T> operation) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
casWithNoReply
in interfaceMemcachedClient
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.casWithNoReply(String, int, GetsResponse, CASOperation)
-
casWithNoReply
public <T> void casWithNoReply(java.lang.String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
Description copied from interface:MemcachedClient
cas noreply- Specified by:
casWithNoReply
in interfaceMemcachedClient
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
cas
public final <T> boolean cas(java.lang.String key, GetsResponse<T> getsReponse, CASOperation<T> operation) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
cas
in interfaceMemcachedClient
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.cas(String, int, GetsResponse, CASOperation, Transcoder)
-
cas
public final <T> boolean cas(java.lang.String key, int exp, CASOperation<T> operation) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
cas
in interfaceMemcachedClient
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.cas(String, int, GetsResponse, CASOperation, Transcoder)
-
cas
public final <T> boolean cas(java.lang.String key, CASOperation<T> operation) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
cas
in interfaceMemcachedClient
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.cas(String, int, GetsResponse, CASOperation, Transcoder)
-
delete
public final boolean delete(java.lang.String key, int time) throws java.util.concurrent.TimeoutException, java.lang.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
- Throws:
java.lang.InterruptedException
MemcachedException
java.util.concurrent.TimeoutException
-
delete
public boolean delete(java.lang.String key, long opTimeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
Description copied from interface:MemcachedClient
Delete key's date item from memcached- Specified by:
delete
in interfaceMemcachedClient
opTimeout
- Operation timeout- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
delete
public boolean delete(java.lang.String key, long cas, long opTimeout) throws java.util.concurrent.TimeoutException, java.lang.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
opTimeout
- Operation timeout- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
deleteWithNoReply
public final void deleteWithNoReply(java.lang.String key, int time) throws java.lang.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:
java.lang.InterruptedException
MemcachedException
-
deleteWithNoReply
public final void deleteWithNoReply(java.lang.String key) throws java.lang.InterruptedException, MemcachedException
- Specified by:
deleteWithNoReply
in interfaceMemcachedClient
- Throws:
java.lang.InterruptedException
MemcachedException
-
delete0
private boolean delete0(java.lang.String key, int time, long cas, boolean noreply, long opTimeout) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
- Throws:
MemcachedException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
-
checkException
protected void checkException(Command command) throws MemcachedException
- Throws:
MemcachedException
-
touch
public boolean touch(java.lang.String key, int exp, long opTimeout) throws java.util.concurrent.TimeoutException, java.lang.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:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
touch
public boolean touch(java.lang.String key, int exp) throws java.util.concurrent.TimeoutException, java.lang.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:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
getAndTouch
public <T> T getAndTouch(java.lang.String key, int newExp, long opTimeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
Description copied from interface:MemcachedClient
Get item and set a new expiration time for it- Specified by:
getAndTouch
in interfaceMemcachedClient
- 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:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
getAndTouch
public <T> T getAndTouch(java.lang.String key, int newExp) throws java.util.concurrent.TimeoutException, java.lang.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
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
incr
public final long incr(java.lang.String key, long delta) throws java.util.concurrent.TimeoutException, java.lang.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
- Returns:
- the new value of the item's data, after the increment operation was carried out.
- Throws:
java.lang.InterruptedException
MemcachedException
java.util.concurrent.TimeoutException
-
incr
public long incr(java.lang.String key, long delta, long initValue) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
incr
in interfaceMemcachedClient
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
incr
public long incr(java.lang.String key, long delta, long initValue, long timeout) throws java.util.concurrent.TimeoutException, java.lang.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:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
incr
public long incr(java.lang.String key, long delta, long initValue, long timeout, int exp) throws java.util.concurrent.TimeoutException, java.lang.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:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
incrWithNoReply
public final void incrWithNoReply(java.lang.String key, long delta) throws java.lang.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
- Throws:
java.lang.InterruptedException
MemcachedException
-
decrWithNoReply
public final void decrWithNoReply(java.lang.String key, long delta) throws java.lang.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
- Throws:
java.lang.InterruptedException
MemcachedException
-
decr
public final long decr(java.lang.String key, long delta) throws java.util.concurrent.TimeoutException, java.lang.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
- Returns:
- the new value of the item's data, after the decrement operation was carried out.
- Throws:
java.lang.InterruptedException
MemcachedException
java.util.concurrent.TimeoutException
-
decr
public long decr(java.lang.String key, long delta, long initValue) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
decr
in interfaceMemcachedClient
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- See Also:
MemcachedClient.decr(java.lang.String,long)
-
decr
public long decr(java.lang.String key, long delta, long initValue, long timeout) throws java.util.concurrent.TimeoutException, java.lang.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:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
decr
public long decr(java.lang.String key, long delta, long initValue, long timeout, int exp) throws java.util.concurrent.TimeoutException, java.lang.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
initValue
- the initial value to be added when value is not foundexp
- 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:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
flushAll
public final void flushAll() throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
Description copied from interface:MemcachedClient
Make All connected memcached's data item invalid- Specified by:
flushAll
in interfaceMemcachedClient
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
flushAllWithNoReply
public void flushAllWithNoReply() throws java.lang.InterruptedException, MemcachedException
- Specified by:
flushAllWithNoReply
in interfaceMemcachedClient
- Throws:
java.lang.InterruptedException
MemcachedException
-
flushAllWithNoReply
public void flushAllWithNoReply(int exptime) throws java.lang.InterruptedException, MemcachedException
- Specified by:
flushAllWithNoReply
in interfaceMemcachedClient
- Throws:
java.lang.InterruptedException
MemcachedException
-
flushAllWithNoReply
public void flushAllWithNoReply(java.net.InetSocketAddress address) throws MemcachedException, java.lang.InterruptedException
- Specified by:
flushAllWithNoReply
in interfaceMemcachedClient
- Throws:
MemcachedException
java.lang.InterruptedException
-
flushAllWithNoReply
public void flushAllWithNoReply(java.net.InetSocketAddress address, int exptime) throws MemcachedException, java.lang.InterruptedException
- Specified by:
flushAllWithNoReply
in interfaceMemcachedClient
- Throws:
MemcachedException
java.lang.InterruptedException
-
flushAll
public final void flushAll(int exptime, long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
flushAll
in interfaceMemcachedClient
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
flushAll
public final void flushAll(long timeout) throws java.util.concurrent.TimeoutException, java.lang.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:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
flushAllMemcachedServers
private void flushAllMemcachedServers(long timeout, boolean noreply, int exptime) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
- Throws:
MemcachedException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
-
setLoggingLevelVerbosity
public void setLoggingLevelVerbosity(java.net.InetSocketAddress address, int level) throws java.util.concurrent.TimeoutException, java.lang.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
level
- logging level- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
setMemcachedLoggingLevel
private void setMemcachedLoggingLevel(java.net.InetSocketAddress address, int level, boolean noreply) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
- Throws:
MemcachedException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
-
setLoggingLevelVerbosityWithNoReply
public void setLoggingLevelVerbosityWithNoReply(java.net.InetSocketAddress address, int level) throws java.lang.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:
java.lang.InterruptedException
MemcachedException
-
flushAll
public final void flushAll(java.net.InetSocketAddress address) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
Description copied from interface:MemcachedClient
Invalidate all existing items immediately- Specified by:
flushAll
in interfaceMemcachedClient
- Parameters:
address
- Target memcached server- Throws:
MemcachedException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
-
flushAll
public final void flushAll(java.net.InetSocketAddress address, long timeout) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
- Specified by:
flushAll
in interfaceMemcachedClient
- Throws:
MemcachedException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
-
flushAll
public final void flushAll(java.net.InetSocketAddress address, long timeout, int exptime) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
- Specified by:
flushAll
in interfaceMemcachedClient
- Throws:
MemcachedException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
-
flushSpecialMemcachedServer
private void flushSpecialMemcachedServer(java.net.InetSocketAddress address, long timeout, boolean noreply, int exptime) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
- Throws:
MemcachedException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
-
flushAll
public final void flushAll(java.lang.String host) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
Description copied from interface:MemcachedClient
This method is deprecated,please use flushAll(InetSocketAddress) instead.- Specified by:
flushAll
in interfaceMemcachedClient
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
stats
public final java.util.Map<java.lang.String,java.lang.String> stats(java.net.InetSocketAddress address) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
- Specified by:
stats
in interfaceMemcachedClient
- Throws:
MemcachedException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
-
stats
public final java.util.Map<java.lang.String,java.lang.String> stats(java.net.InetSocketAddress address, long timeout) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
Description copied from interface:MemcachedClient
�ョ��瑰������emcached server缁��淇℃�- Specified by:
stats
in interfaceMemcachedClient
- Parameters:
address
- ����板�timeout
- ���瓒��- Returns:
- Throws:
MemcachedException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
-
getStats
public final java.util.Map<java.net.InetSocketAddress,java.util.Map<java.lang.String,java.lang.String>> getStats() throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
- Specified by:
getStats
in interfaceMemcachedClient
- Throws:
MemcachedException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
-
getStatsByItem
public final java.util.Map<java.net.InetSocketAddress,java.util.Map<java.lang.String,java.lang.String>> getStatsByItem(java.lang.String itemName) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
Description copied from interface:MemcachedClient
Get special item stats. "stats items" for example- Specified by:
getStatsByItem
in interfaceMemcachedClient
- Returns:
- Throws:
MemcachedException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
-
getStatsByItem
public final java.util.Map<java.net.InetSocketAddress,java.util.Map<java.lang.String,java.lang.String>> getStatsByItem(java.lang.String itemName, long timeout) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
- Specified by:
getStatsByItem
in interfaceMemcachedClient
- Throws:
MemcachedException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
-
getVersions
public final java.util.Map<java.net.InetSocketAddress,java.lang.String> getVersions() throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
Description copied from interface:MemcachedClient
Get all connected memcached servers's version.- Specified by:
getVersions
in interfaceMemcachedClient
- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
getVersions
public final java.util.Map<java.net.InetSocketAddress,java.lang.String> getVersions(long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
getVersions
in interfaceMemcachedClient
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
getStats
public java.util.Map<java.net.InetSocketAddress,java.util.Map<java.lang.String,java.lang.String>> getStats(long timeout) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
Description copied from interface:MemcachedClient
Get stats from all memcached servers- Specified by:
getStats
in interfaceMemcachedClient
- Returns:
- server->item->value map
- Throws:
MemcachedException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
-
shutdown0
protected void shutdown0()
For subclass override.
-
shutdown
public final void shutdown() throws java.io.IOException
- Specified by:
shutdown
in interfaceMemcachedClient
- Throws:
java.io.IOException
-
sendIncrOrDecrCommand
private long sendIncrOrDecrCommand(java.lang.String key, long delta, long initValue, CommandType cmdType, boolean noreply, long operationTimeout, int exp) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException, MemcachedException
- Throws:
java.lang.InterruptedException
java.util.concurrent.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(java.lang.String key) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Specified by:
delete
in interfaceMemcachedClient
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
getTranscoder
public final Transcoder getTranscoder()
Description copied from interface:MemcachedClient
return default transcoder,default is SerializingTranscoder- Specified by:
getTranscoder
in interfaceMemcachedClient
- Returns:
-
setTranscoder
public final void setTranscoder(Transcoder transcoder)
Description copied from interface:MemcachedClient
set transcoder- Specified by:
setTranscoder
in interfaceMemcachedClient
-
sendStoreCommand
private final <T> boolean sendStoreCommand(Command command, long timeout) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException, MemcachedException
- Throws:
java.lang.InterruptedException
java.util.concurrent.TimeoutException
MemcachedException
-
latchWait
protected void latchWait(Command cmd, long timeout, Session session) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException
- Throws:
java.lang.InterruptedException
java.util.concurrent.TimeoutException
-
getContinuousTimeoutCounter
private java.util.concurrent.atomic.AtomicInteger getContinuousTimeoutCounter(Session session)
-
getAvaliableServers
@Deprecated public final java.util.Collection<java.net.InetSocketAddress> getAvaliableServers()
Deprecated.Use getAvailableServers() instead- Specified by:
getAvaliableServers
in interfaceMemcachedClient
- Returns:
- See Also:
MemcachedClient.getAvailableServers()
-
getAvailableServers
public java.util.Collection<java.net.InetSocketAddress> getAvailableServers()
Description copied from interface:MemcachedClient
Returns available memcached servers list.- Specified by:
getAvailableServers
in interfaceMemcachedClient
- Returns:
- A available server collection
-
getConnectionSizeBySocketAddress
public final int getConnectionSizeBySocketAddress(java.net.InetSocketAddress address)
-
addStateListener
public void addStateListener(MemcachedClientStateListener listener)
Description copied from interface:MemcachedClient
Add a memcached client listener- Specified by:
addStateListener
in interfaceMemcachedClient
-
getStateListeners
public java.util.Collection<MemcachedClientStateListener> 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
public void removeStateListener(MemcachedClientStateListener listener)
Description copied from interface:MemcachedClient
Remove a memcached client listener- Specified by:
removeStateListener
in interfaceMemcachedClient
-
getProtocol
public Protocol 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 java.lang.String decodeKey(java.lang.String key) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
- Throws:
MemcachedException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
-
preProcessKey
private java.lang.String preProcessKey(java.lang.String key) throws MemcachedException, java.lang.InterruptedException
- Throws:
MemcachedException
java.lang.InterruptedException
-
invalidateNamespace
public void invalidateNamespace(java.lang.String ns, long opTimeout) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.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
java.lang.InterruptedException
java.util.concurrent.TimeoutException
-
invalidateNamespace
public void invalidateNamespace(java.lang.String ns) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.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
java.lang.InterruptedException
java.util.concurrent.TimeoutException
-
getNamespace
public java.lang.String getNamespace(java.lang.String ns) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
Returns the real namespace of ns.- Parameters:
ns
-- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
getNSKey
private java.lang.String getNSKey(java.lang.String ns)
-
getCounter
public Counter getCounter(java.lang.String key, long initialValue)
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
- Returns:
-
getCounter
public Counter getCounter(java.lang.String key)
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
- Returns:
-
getKeyIterator
@Deprecated public KeyIterator getKeyIterator(java.net.InetSocketAddress address) throws MemcachedException, java.util.concurrent.TimeoutException, java.lang.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
- Returns:
- Throws:
MemcachedException
java.util.concurrent.TimeoutException
java.lang.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
-
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
public java.util.Queue<ReconnectRequest> 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.
-
-