Package net.rubyeye.xmemcached
Interface MemcachedClient
-
- All Known Implementing Classes:
AWSElasticCacheClient,XMemcachedClient
public interface MemcachedClientThe memcached client's interface
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_CONNECT_TIMEOUTDefault connect timeout,1 minutesstatic intDEFAULT_CONNECTION_POOL_SIZEWith java nio,there is only one connection to a memcached.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.static longDEFAULT_HEAL_SESSION_INTERVALDefault heal session interval in milliseconds.static intDEFAULT_MAX_QUEUED_NOPSDefault max queued noreply operations number.It is calcuated dynamically based on your jvm maximum memory.static intDEFAULT_MAX_TIMEOUTEXCEPTION_THRESHOLDMaximum number of timeout exception for close connection.static longDEFAULT_OP_TIMEOUTDefault operation timeout,if the operation is not returned in 5 second,throw TimeoutException.static intDEFAULT_READ_THREAD_COUNTDefault thread number for reading nio's receive buffer and dispatch commands.Recommend users to set it equal or less to the memcached server's number on linux platform,keep default on windows.Default is 0.static intDEFAULT_SESSION_IDLE_TIMEOUTDefault session idle timeout,if session is idle,xmemcached will do a heartbeat action to check if connection is alive.static intDEFAULT_SESSION_READ_BUFF_SIZEDefault session read buffer size,16kstatic booleanDEFAULT_TCP_KEEPLIVEDefault TCP keeplive option,which is truestatic booleanDEFAULT_TCP_NO_DELAYDisable nagle algorithm by defaultstatic intDEFAULT_TCP_RECV_BUFF_SIZEDefault socket's receive buffer size,16kstatic intDEFAULT_TCP_SEND_BUFF_SIZEDefault socket's send buffer size,8kstatic intDYNAMIC_MAX_QUEUED_NOPSstatic intMAX_QUEUED_NOPS
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description booleanadd(java.lang.String key, int exp, java.lang.Object value)booleanadd(java.lang.String key, int exp, java.lang.Object value, long timeout)<T> booleanadd(java.lang.String key, int exp, T value, Transcoder<T> transcoder)<T> booleanadd(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.voidaddServer(java.lang.String hostList)Add many memcached servers.You can call this method through JMX or programvoidaddServer(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)voidaddServer(java.lang.String server, int port, int weight)add a memcached server to MemcachedClientvoidaddServer(java.net.InetSocketAddress inetSocketAddress)Add a memcached server,the thread call this method will be blocked until the connecting operations completed(success or fail)voidaddServer(java.net.InetSocketAddress inetSocketAddress, int weight)voidaddStateListener(MemcachedClientStateListener listener)Add a memcached client listenervoidaddWithNoReply(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> voidaddWithNoReply(java.lang.String key, int exp, T value, Transcoder<T> transcoder)booleanappend(java.lang.String key, java.lang.Object value)booleanappend(java.lang.String key, java.lang.Object value, long timeout)Append value to key's data item,this method will wait for replyvoidappendWithNoReply(java.lang.String key, java.lang.Object value)Append value to key's data item,this method doesn't wait for reply.voidbeginWithNamespace(java.lang.String ns)set current namespace for following operations with memcached client.It must be ended withendWithNamespace()method.For example:booleancas(java.lang.String key, int exp, java.lang.Object value, long cas)booleancas(java.lang.String key, int exp, java.lang.Object value, long timeout, long cas)<T> booleancas(java.lang.String key, int exp, CASOperation<T> operation)<T> booleancas(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> booleancas(java.lang.String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation)<T> booleancas(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> booleancas(java.lang.String key, int exp, T value, Transcoder<T> transcoder, long cas)<T> booleancas(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> booleancas(java.lang.String key, CASOperation<T> operation)<T> booleancas(java.lang.String key, GetsResponse<T> getsResponse, CASOperation<T> operation)<T> voidcasWithNoReply(java.lang.String key, int exp, CASOperation<T> operation)<T> voidcasWithNoReply(java.lang.String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation)cas noreply<T> voidcasWithNoReply(java.lang.String key, CASOperation<T> operation)<T> voidcasWithNoReply(java.lang.String key, GetsResponse<T> getsResponse, CASOperation<T> operation)longdecr(java.lang.String key, long delta)"decr" are used to change data for some item in-place, decrementing it.longdecr(java.lang.String key, long delta, long initValue)longdecr(java.lang.String key, long delta, long initValue, long timeout)"decr" are used to change data for some item in-place, decrementing it.longdecr(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.voiddecrWithNoReply(java.lang.String key, long delta)"decr" are used to change data for some item in-place, decrementing it.booleandelete(java.lang.String key)booleandelete(java.lang.String key, int time)Deprecated.booleandelete(java.lang.String key, long opTimeout)Delete key's date item from memcachedbooleandelete(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.voiddeleteWithNoReply(java.lang.String key)voiddeleteWithNoReply(java.lang.String key, int time)Deprecated.voidendWithNamespace()Remove current namespace set for this memcached client.It must begin withbeginWithNamespace(String)method.voidflushAll()Make All connected memcached's data item invalidvoidflushAll(int exptime, long timeout)voidflushAll(long timeout)Make All connected memcached's data item invalidvoidflushAll(java.lang.String host)Deprecated.voidflushAll(java.net.InetSocketAddress address)Invalidate all existing items immediatelyvoidflushAll(java.net.InetSocketAddress address, long timeout)voidflushAll(java.net.InetSocketAddress address, long timeout, int exptime)voidflushAllWithNoReply()voidflushAllWithNoReply(int exptime)voidflushAllWithNoReply(java.net.InetSocketAddress address)voidflushAllWithNoReply(java.net.InetSocketAddress address, int exptime)<T> Tget(java.lang.String key)<T> Tget(java.lang.String key, long timeout)<T> Tget(java.lang.String key, long timeout, Transcoder<T> transcoder)Get value by key<T> Tget(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 opTimeout, 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)<T> TgetAndTouch(java.lang.String key, int newExp)Get item and set a new expiration time for it,using default opTimeout<T> TgetAndTouch(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.ConnectorgetConnector()return the session managerlonggetConnectTimeout()Get the connect timeoutCountergetCounter(java.lang.String key)Get counter for key,and if the key's value is not set,then set it with 0.CountergetCounter(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.longgetHealSessionInterval()Return the default heal session interval in millisecondsKeyIteratorgetKeyIterator(java.net.InetSocketAddress address)Deprecated.memcached 1.6.x will remove cachedump stats command,so this method will be removed in the futurejava.lang.StringgetName()Return the cache instance namelonggetOpTimeout()get operation timeout settingProtocolgetProtocol()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 opTime, 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)java.util.List<java.lang.String>getServersDescription()Get current server list.You can call this method through JMX or programjava.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)intgetTimeoutExceptionThreshold()Returns maximum number of timeout exception for closing connection.TranscodergetTranscoder()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)longincr(java.lang.String key, long delta)"incr" are used to change data for some item in-place, incrementing it.longincr(java.lang.String key, long delta, long initValue)longincr(java.lang.String key, long delta, long initValue, long timeout)"incr" are used to change data for some item in-place, incrementing it.longincr(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.voidincrWithNoReply(java.lang.String key, long delta)"incr" are used to change data for some item in-place, incrementing it.voidinvalidateNamespace(java.lang.String ns)Invalidate all namespace under the namespace using the default operation timeout.voidinvalidateNamespace(java.lang.String ns, long opTimeout)Invalidate all items under the namespace.booleanisFailureMode()Returns if client is in failure mode.booleanisSanitizeKeys()booleanisShutdown()booleanprepend(java.lang.String key, java.lang.Object value)booleanprepend(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.voidprependWithNoReply(java.lang.String key, java.lang.Object value)Prepend value to key's data item in memcached.This method doesn't wait for reply.voidremoveServer(java.lang.String hostList)Remove many memcached servervoidremoveServer(java.net.InetSocketAddress address)Remove memcached server with the exact given address.voidremoveStateListener(MemcachedClientStateListener listener)Remove a memcached client listenerbooleanreplace(java.lang.String key, int exp, java.lang.Object value)booleanreplace(java.lang.String key, int exp, java.lang.Object value, long timeout)<T> booleanreplace(java.lang.String key, int exp, T value, Transcoder<T> transcoder)<T> booleanreplace(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.voidreplaceWithNoReply(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> voidreplaceWithNoReply(java.lang.String key, int exp, T value, Transcoder<T> transcoder)booleanset(java.lang.String key, int exp, java.lang.Object value)booleanset(java.lang.String key, int exp, java.lang.Object value, long timeout)<T> booleanset(java.lang.String key, int exp, T value, Transcoder<T> transcoder)<T> booleanset(java.lang.String key, int exp, T value, Transcoder<T> transcoder, long timeout)Store key-value item to memcachedvoidsetAuthInfoMap(java.util.Map<java.net.InetSocketAddress,AuthInfo> map)Configure auth infovoidsetBufferAllocator(BufferAllocator bufferAllocator)Deprecated.voidsetConnectionPoolSize(int poolSize)In a high concurrent enviroment,you may want to pool memcached clients.But a xmemcached client has to start a reactor thread and some thread pools,if you create too many clients,the cost is very large.voidsetConnectTimeout(long connectTimeout)Set the connect timeout,default is 1 minutesvoidsetEnableHealSession(boolean enableHealSession)If the memcached dump or network error cause connection closed,xmemcached would try to heal the connection.You can disable this behaviour by using this method:
client.setEnableHealSession(false);
The default value is true.voidsetEnableHeartBeat(boolean enableHeartBeat)Whether to enable heart beatvoidsetFailureMode(boolean failureMode)Configure wheather to set client in failure mode.If set it to true,that means you want to configure client in failure mode.voidsetHealSessionInterval(long healConnectionInterval)If the memcached dump or network error cause connection closed,xmemcached would try to heal the connection.The interval between reconnections is 2 seconds by default.voidsetKeyProvider(KeyProvider keyProvider)Set a key provider for pre-processing keys before sending them to memcached.voidsetLoggingLevelVerbosity(java.net.InetSocketAddress address, int level)Set the verbosity level of the memcached's logging output.This method will wait for reply.voidsetLoggingLevelVerbosityWithNoReply(java.net.InetSocketAddress address, int level)Set the verbosity level of the memcached's logging output.This method doesn't wait for reply from servervoidsetMergeFactor(int mergeFactor)Set the merge factor,this factor determins how many 'get' commands would be merge to one multi-get command.default is 150voidsetName(java.lang.String name)Set cache instance namevoidsetOpTimeout(long opTimeout)set operation timeout,default is one second.voidsetOptimizeGet(boolean optimizeGet)Enable/Disable merge many get commands to one multi-get command.true is to enable it,false is to disable it.Default is true.Recommend users to enable it.voidsetOptimizeMergeBuffer(boolean optimizeMergeBuffer)Enable/Disable merge many command's buffers to one big buffer fit socket's send buffer size.Default is true.Recommend true.voidsetPrimitiveAsString(boolean primitiveAsString)Store all primitive type as string,defualt is false.voidsetSanitizeKeys(boolean sanitizeKey)Enables/disables sanitizing keys by URLEncoding.voidsetTimeoutExceptionThreshold(int timeoutExceptionThreshold)Set maximum number of timeout exception for closing connection.You can set it to be a large value to disable this feature.voidsetTranscoder(Transcoder transcoder)set transcodervoidsetWithNoReply(java.lang.String key, int exp, java.lang.Object value)Store key-value item to memcached,doesn't wait for reply<T> voidsetWithNoReply(java.lang.String key, int exp, T value, Transcoder<T> transcoder)voidshutdown()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缁��淇℃�booleantouch(java.lang.String key, int exp)Set a new expiration time for an existing item,using default opTimeout second.booleantouch(java.lang.String key, int exp, long opTimeout)Set a new expiration time for an existing item<T> TwithNamespace(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
-
DEFAULT_READ_THREAD_COUNT
static final int DEFAULT_READ_THREAD_COUNT
Default thread number for reading nio's receive buffer and dispatch commands.Recommend users to set it equal or less to the memcached server's number on linux platform,keep default on windows.Default is 0.- See Also:
- Constant Field Values
-
DEFAULT_TCP_KEEPLIVE
static final boolean DEFAULT_TCP_KEEPLIVE
Default TCP keeplive option,which is true- See Also:
- Constant Field Values
-
DEFAULT_CONNECT_TIMEOUT
static final int DEFAULT_CONNECT_TIMEOUT
Default connect timeout,1 minutes- See Also:
- Constant Field Values
-
DEFAULT_TCP_SEND_BUFF_SIZE
static final int DEFAULT_TCP_SEND_BUFF_SIZE
Default socket's send buffer size,8k- See Also:
- Constant Field Values
-
DEFAULT_TCP_NO_DELAY
static final boolean DEFAULT_TCP_NO_DELAY
Disable nagle algorithm by default- See Also:
- Constant Field Values
-
DEFAULT_SESSION_READ_BUFF_SIZE
static final int DEFAULT_SESSION_READ_BUFF_SIZE
Default session read buffer size,16k- See Also:
- Constant Field Values
-
DEFAULT_TCP_RECV_BUFF_SIZE
static final int DEFAULT_TCP_RECV_BUFF_SIZE
Default socket's receive buffer size,16k- See Also:
- Constant Field Values
-
DEFAULT_OP_TIMEOUT
static final long DEFAULT_OP_TIMEOUT
Default operation timeout,if the operation is not returned in 5 second,throw TimeoutException.- See Also:
- Constant Field Values
-
DEFAULT_CONNECTION_POOL_SIZE
static final int DEFAULT_CONNECTION_POOL_SIZE
With java nio,there is only one connection to a memcached.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.Default pool size is 1.- See Also:
- Constant Field Values
-
DEFAULT_SESSION_IDLE_TIMEOUT
static final int DEFAULT_SESSION_IDLE_TIMEOUT
Default session idle timeout,if session is idle,xmemcached will do a heartbeat action to check if connection is alive.- See Also:
- Constant Field Values
-
DEFAULT_HEAL_SESSION_INTERVAL
static final long DEFAULT_HEAL_SESSION_INTERVAL
Default heal session interval in milliseconds.- See Also:
- Constant Field Values
-
MAX_QUEUED_NOPS
static final int MAX_QUEUED_NOPS
- See Also:
- Constant Field Values
-
DYNAMIC_MAX_QUEUED_NOPS
static final int DYNAMIC_MAX_QUEUED_NOPS
-
DEFAULT_MAX_QUEUED_NOPS
static final int DEFAULT_MAX_QUEUED_NOPS
Default max queued noreply operations number.It is calcuated dynamically based on your jvm maximum memory.- Since:
- 1.3.8
-
DEFAULT_MAX_TIMEOUTEXCEPTION_THRESHOLD
static final int DEFAULT_MAX_TIMEOUTEXCEPTION_THRESHOLD
Maximum number of timeout exception for close connection.- Since:
- 1.4.0
- See Also:
- Constant Field Values
-
-
Method Detail
-
setMergeFactor
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 150- Parameters:
mergeFactor-
-
getConnectTimeout
long getConnectTimeout()
Get the connect timeout
-
setConnectTimeout
void setConnectTimeout(long connectTimeout)
Set the connect timeout,default is 1 minutes- Parameters:
connectTimeout-
-
getConnector
Connector getConnector()
return the session manager- Returns:
-
setOptimizeGet
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.- Parameters:
optimizeGet-
-
setOptimizeMergeBuffer
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.- Parameters:
optimizeMergeBuffer-
-
isShutdown
boolean isShutdown()
- Returns:
-
addServer
void addServer(java.lang.String server, int port) throws java.io.IOExceptionAadd a memcached server,the thread call this method will be blocked until the connecting operations completed(success or fail)- Parameters:
server- host stringport- port number- Throws:
java.io.IOException
-
addServer
void addServer(java.net.InetSocketAddress inetSocketAddress) throws java.io.IOExceptionAdd a memcached server,the thread call this method will be blocked until the connecting operations completed(success or fail)- Parameters:
inetSocketAddress- memcached server's socket address- Throws:
java.io.IOException
-
addServer
void addServer(java.lang.String hostList) throws java.io.IOExceptionAdd many memcached servers.You can call this method through JMX or program- Parameters:
host- String like [host1]:[port1] [host2]:[port2] ...- Throws:
java.io.IOException
-
getServersDescription
java.util.List<java.lang.String> getServersDescription()
Get current server list.You can call this method through JMX or program
-
removeServer
void removeServer(java.lang.String hostList)
Remove many memcached server- Parameters:
host- String like [host1]:[port1] [host2]:[port2] ...
-
removeServer
void removeServer(java.net.InetSocketAddress address)
Remove memcached server with the exact given address.- Parameters:
address- Resolved server address
-
setBufferAllocator
@Deprecated void setBufferAllocator(BufferAllocator bufferAllocator)
Deprecated.Set the nio's ByteBuffer Allocator,use SimpleBufferAllocator by default.- Parameters:
bufferAllocator-
-
get
<T> T get(java.lang.String key, long timeout, Transcoder<T> transcoder) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedExceptionGet value by key- Type Parameters:
T-- Parameters:
key- Keytimeout- Operation timeout,if the method is not returned in this time,throw TimeoutExceptiontranscoder- The value's transcoder- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
get
<T> T get(java.lang.String key, long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
get
<T> T get(java.lang.String key, Transcoder<T> transcoder) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
get
<T> T get(java.lang.String key) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
gets
<T> GetsResponse<T> gets(java.lang.String key, long timeout, Transcoder<T> transcoder) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
Just like get,But it return a GetsResponse,include cas value for cas update.- Type Parameters:
T-- Parameters:
key- keytimeout- operation timeouttranscoder-- Returns:
- GetsResponse
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
gets
<T> GetsResponse<T> gets(java.lang.String key) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Type Parameters:
T-- Parameters:
key-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
gets(String, long, Transcoder)
-
gets
<T> GetsResponse<T> gets(java.lang.String key, long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Type Parameters:
T-- Parameters:
key-timeout-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
gets(String, long, Transcoder)
-
gets
<T> GetsResponse<T> gets(java.lang.String key, Transcoder transcoder) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Type Parameters:
T-- Parameters:
key-transcoder-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
gets(String, long, Transcoder)
-
get
<T> java.util.Map<java.lang.String,T> get(java.util.Collection<java.lang.String> keyCollections, long opTimeout, Transcoder<T> transcoder) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedExceptionBulk get items- Type Parameters:
T-- Parameters:
keyCollections- key collectionopTimeout- opTimeouttranscoder- Value transcoder- Returns:
- Exists items map
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
get
<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- Type Parameters:
T-- Parameters:
keyCollections-transcoder-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
get(Collection, long, Transcoder)
-
get
<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- Type Parameters:
T-- Parameters:
keyCollections-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
get(Collection, long, Transcoder)
-
get
<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- Type Parameters:
T-- Parameters:
keyCollections-timeout-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
get(Collection, long, Transcoder)
-
gets
<T> java.util.Map<java.lang.String,GetsResponse<T>> gets(java.util.Collection<java.lang.String> keyCollections, long opTime, Transcoder<T> transcoder) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
Bulk gets items- Type Parameters:
T-- Parameters:
keyCollections- key collectionopTime- Operation timeouttranscoder- Value transcoder- Returns:
- Exists GetsResponse map
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
GetsResponse
-
gets
<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
- Type Parameters:
T-- Parameters:
keyCollections-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
gets(Collection, long, Transcoder)
-
gets
<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
- Type Parameters:
T-- Parameters:
keyCollections-timeout-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
gets(Collection, long, Transcoder)
-
gets
<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
- Type Parameters:
T-- Parameters:
keyCollections-transcoder-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
gets(Collection, long, Transcoder)
-
set
<T> boolean set(java.lang.String key, int exp, T value, Transcoder<T> transcoder, long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedExceptionStore key-value item to memcached- Type Parameters:
T-- Parameters:
key- stored keyexp- An expiration time, in seconds. Can be up to 30 days. After 30 days, is treated as a unix timestamp of an exact date.value- stored datatranscoder- transocdertimeout- operation timeout,in milliseconds- Returns:
- boolean result
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
set
boolean set(java.lang.String key, int exp, java.lang.Object value) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
set(String, int, Object, Transcoder, long)
-
set
boolean set(java.lang.String key, int exp, java.lang.Object value, long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
set(String, int, Object, Transcoder, long)
-
set
<T> boolean set(java.lang.String key, int exp, T value, Transcoder<T> transcoder) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
set(String, int, Object, Transcoder, long)
-
setWithNoReply
void setWithNoReply(java.lang.String key, int exp, java.lang.Object value) throws java.lang.InterruptedException, MemcachedExceptionStore key-value item to memcached,doesn't wait for reply- Type Parameters:
T-- Parameters:
key- stored keyexp- An expiration time, in seconds. Can be up to 30 days. After 30 days, is treated as a unix timestamp of an exact date.value- stored datatranscoder- transocder- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
setWithNoReply
<T> void setWithNoReply(java.lang.String key, int exp, T value, Transcoder<T> transcoder) throws java.lang.InterruptedException, MemcachedException- Type Parameters:
T-- Parameters:
key-exp-value-transcoder-- Throws:
java.lang.InterruptedExceptionMemcachedException- See Also:
setWithNoReply(String, int, Object, Transcoder)
-
add
<T> boolean add(java.lang.String key, int exp, T value, Transcoder<T> transcoder, long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedExceptionAdd key-value item to memcached, success only when the key is not exists in memcached.- Type Parameters:
T-- Parameters:
key-exp- An expiration time, in seconds. Can be up to 30 days. After 30 days, is treated as a unix timestamp of an exact date.value-transcoder-timeout-- Returns:
- boolean result
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
add
boolean add(java.lang.String key, int exp, java.lang.Object value) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Parameters:
key-exp-value-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
add(String, int, Object, Transcoder, long)
-
add
boolean add(java.lang.String key, int exp, java.lang.Object value, long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Parameters:
key-exp-value-timeout-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
add(String, int, Object, Transcoder, long)
-
add
<T> boolean add(java.lang.String key, int exp, T value, Transcoder<T> transcoder) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Type Parameters:
T-- Parameters:
key-exp-value-transcoder-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
add(String, int, Object, Transcoder, long)
-
addWithNoReply
void addWithNoReply(java.lang.String key, int exp, java.lang.Object value) throws java.lang.InterruptedException, MemcachedExceptionAdd key-value item to memcached, success only when the key is not exists in memcached.This method doesn't wait for reply.- Type Parameters:
T-- Parameters:
key-exp- An expiration time, in seconds. Can be up to 30 days. After 30 days, is treated as a unix timestamp of an exact date.value-transcoder-- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
addWithNoReply
<T> void addWithNoReply(java.lang.String key, int exp, T value, Transcoder<T> transcoder) throws java.lang.InterruptedException, MemcachedException- Type Parameters:
T-- Parameters:
key-exp-value-transcoder-- Throws:
java.lang.InterruptedExceptionMemcachedException- See Also:
addWithNoReply(String, int, Object, Transcoder)
-
replace
<T> boolean replace(java.lang.String key, int exp, T value, Transcoder<T> transcoder, long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedExceptionReplace 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.- Type Parameters:
T-- Parameters:
key-exp- An expiration time, in seconds. Can be up to 30 days. After 30 days, is treated as a unix timestamp of an exact date.value-transcoder-timeout-- Returns:
- boolean result
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
replace
boolean replace(java.lang.String key, int exp, java.lang.Object value) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Parameters:
key-exp-value-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
replace(String, int, Object, Transcoder, long)
-
replace
boolean replace(java.lang.String key, int exp, java.lang.Object value, long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Parameters:
key-exp-value-timeout-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
replace(String, int, Object, Transcoder, long)
-
replace
<T> boolean replace(java.lang.String key, int exp, T value, Transcoder<T> transcoder) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Type Parameters:
T-- Parameters:
key-exp-value-transcoder-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
replace(String, int, Object, Transcoder, long)
-
replaceWithNoReply
void replaceWithNoReply(java.lang.String key, int exp, java.lang.Object value) throws java.lang.InterruptedException, MemcachedExceptionReplace 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.- Type Parameters:
T-- Parameters:
key-exp- An expiration time, in seconds. Can be up to 30 days. After 30 days, is treated as a unix timestamp of an exact date.value-transcoder-- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
replaceWithNoReply
<T> void replaceWithNoReply(java.lang.String key, int exp, T value, Transcoder<T> transcoder) throws java.lang.InterruptedException, MemcachedException- Type Parameters:
T-- Parameters:
key-exp-value-transcoder-- Throws:
java.lang.InterruptedExceptionMemcachedException- See Also:
replaceWithNoReply(String, int, Object, Transcoder)
-
append
boolean append(java.lang.String key, java.lang.Object value) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Parameters:
key-value-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
append(String, Object, long)
-
append
boolean append(java.lang.String key, java.lang.Object value, long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedExceptionAppend value to key's data item,this method will wait for reply- Parameters:
key-value-timeout-- Returns:
- boolean result
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
appendWithNoReply
void appendWithNoReply(java.lang.String key, java.lang.Object value) throws java.lang.InterruptedException, MemcachedExceptionAppend value to key's data item,this method doesn't wait for reply.- Parameters:
key-value-- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
prepend
boolean prepend(java.lang.String key, java.lang.Object value) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Parameters:
key-value-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
prepend(String, Object, long)
-
prepend
boolean prepend(java.lang.String key, java.lang.Object value, long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedExceptionPrepend value to key's data item in memcached.This method doesn't wait for reply.- Parameters:
key-value-- Returns:
- boolean result
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
prependWithNoReply
void prependWithNoReply(java.lang.String key, java.lang.Object value) throws java.lang.InterruptedException, MemcachedExceptionPrepend value to key's data item in memcached.This method doesn't wait for reply.- Parameters:
key-value-- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
cas
boolean cas(java.lang.String key, int exp, java.lang.Object value, long cas) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Parameters:
key-exp-value-cas-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
cas(String, int, Object, Transcoder, long, long)
-
cas
<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, MemcachedExceptionCas is a check and set operation which means "store this data but only if no one else has updated since I last fetched it."- Type Parameters:
T-- Parameters:
key-exp- An expiration time, in seconds. Can be up to 30 days. After 30 days, is treated as a unix timestamp of an exact date.value-transcoder-timeout-cas-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
cas
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- Parameters:
key-exp-value-timeout-cas-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
cas(String, int, Object, Transcoder, long, long)
-
cas
<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- Type Parameters:
T-- Parameters:
key-exp-value-transcoder-cas-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
cas(String, int, Object, Transcoder, long, long)
-
cas
<T> boolean cas(java.lang.String key, int exp, CASOperation<T> operation, Transcoder<T> transcoder) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedExceptionCas is a check and set operation which means "store this data but only if no one else has updated since I last fetched it."- Type Parameters:
T-- Parameters:
key-exp- An expiration time, in seconds. Can be up to 30 days. After 30 days, is treated as a unix timestamp of an exact date.operation- CASOperationtranscoder- object transcoder- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
cas
<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, MemcachedExceptioncas is a check and set operation which means "store this data but only if no one else has updated since I last fetched it."- Type Parameters:
T-- Parameters:
key-exp- An expiration time, in seconds. Can be up to 30 days. After 30 days, is treated as a unix timestamp of an exact date.getsReponse- gets method's resultoperation- CASOperationtranscoder-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
cas
<T> boolean cas(java.lang.String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Type Parameters:
T-- Parameters:
key-exp-getsReponse-operation-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
cas(String, int, GetsResponse, CASOperation, Transcoder)
-
cas
<T> boolean cas(java.lang.String key, GetsResponse<T> getsResponse, CASOperation<T> operation) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Type Parameters:
T-- Parameters:
key-getsResponse-operation-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
cas(String, int, GetsResponse, CASOperation, Transcoder)
-
cas
<T> boolean cas(java.lang.String key, int exp, CASOperation<T> operation) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Type Parameters:
T-- Parameters:
key-exp-operation-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
cas(String, int, GetsResponse, CASOperation, Transcoder)
-
cas
<T> boolean cas(java.lang.String key, CASOperation<T> operation) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Type Parameters:
T-- Parameters:
key-operation-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
cas(String, int, GetsResponse, CASOperation, Transcoder)
-
casWithNoReply
<T> void casWithNoReply(java.lang.String key, GetsResponse<T> getsResponse, CASOperation<T> operation) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Type Parameters:
T-- Parameters:
key-getsResponse-operation-- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
casWithNoReply
<T> void casWithNoReply(java.lang.String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedExceptioncas noreply- Type Parameters:
T-- Parameters:
key-exp-getsReponse-operation-- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
casWithNoReply
<T> void casWithNoReply(java.lang.String key, int exp, CASOperation<T> operation) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Type Parameters:
T-- Parameters:
key-exp-operation-- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
casWithNoReply(String, int, GetsResponse, CASOperation)
-
casWithNoReply
<T> void casWithNoReply(java.lang.String key, CASOperation<T> operation) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Type Parameters:
T-- Parameters:
key-operation-- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
casWithNoReply(String, int, GetsResponse, CASOperation)
-
delete
@Deprecated boolean delete(java.lang.String key, int time) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedExceptionDeprecated.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.- Parameters:
key-time-- Throws:
java.lang.InterruptedExceptionMemcachedExceptionjava.util.concurrent.TimeoutException
-
delete
boolean delete(java.lang.String key, long opTimeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedExceptionDelete key's date item from memcached- Parameters:
key-opTimeout- Operation timeout- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- Since:
- 1.3.2
-
delete
boolean delete(java.lang.String key, long cas, long opTimeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedExceptionDelete key's date item from memcached only if its cas value is the same as what was read.- Parameters:
key-opTimeout- Operation timeout- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- Since:
- 1.3.2
-
touch
boolean touch(java.lang.String key, int exp, long opTimeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedExceptionSet a new expiration time for an existing item- 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.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
touch
boolean touch(java.lang.String key, int exp) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedExceptionSet a new expiration time for an existing item,using default opTimeout second.- 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.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
getAndTouch
<T> T getAndTouch(java.lang.String key, int newExp, long opTimeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedExceptionGet item and set a new expiration time for it- Type Parameters:
T-- Parameters:
key- item's keynewExp- New expiration time, in seconds. Can be up to 30 days. After 30 days, is treated as a unix timestamp of an exact date.opTimeout- operation timeout- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
getAndTouch
<T> T getAndTouch(java.lang.String key, int newExp) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedExceptionGet item and set a new expiration time for it,using default opTimeout- Type Parameters:
T-- Parameters:
key-newExp-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
getVersions
java.util.Map<java.net.InetSocketAddress,java.lang.String> getVersions() throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedExceptionGet all connected memcached servers's version.- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
incr
long incr(java.lang.String key, long delta) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException"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.- Parameters:
key-num-- Returns:
- the new value of the item's data, after the increment operation was carried out.
- Throws:
java.lang.InterruptedExceptionMemcachedExceptionjava.util.concurrent.TimeoutException
-
incr
long incr(java.lang.String key, long delta, long initValue) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
incr
long incr(java.lang.String key, long delta, long initValue, long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException"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.- Parameters:
key- keynum- incrementinitValue- initValue if the data is not exists.timeout- operation timeout- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
decr
long decr(java.lang.String key, long delta) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException"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.- Parameters:
key-num-- Returns:
- the new value of the item's data, after the decrement operation was carried out.
- Throws:
java.lang.InterruptedExceptionMemcachedExceptionjava.util.concurrent.TimeoutException
-
decr
long decr(java.lang.String key, long delta, long initValue) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Parameters:
key-num-initValue-- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException- See Also:
decr(java.lang.String,long)
-
decr
long decr(java.lang.String key, long delta, long initValue, long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException"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.- Parameters:
key- The keynum- The incrementinitValue- The initial value if the data is not exists.timeout- Operation timeout- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
flushAll
void flushAll() throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedExceptionMake All connected memcached's data item invalid- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
flushAllWithNoReply
void flushAllWithNoReply() throws java.lang.InterruptedException, MemcachedException- Throws:
java.lang.InterruptedExceptionMemcachedException
-
flushAll
void flushAll(long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedExceptionMake All connected memcached's data item invalid- Parameters:
timeout- operation timeout- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
flushAll
void flushAll(java.net.InetSocketAddress address) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutExceptionInvalidate all existing items immediately- Parameters:
address- Target memcached servertimeout- operation timeout- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
flushAllWithNoReply
void flushAllWithNoReply(java.net.InetSocketAddress address) throws MemcachedException, java.lang.InterruptedException- Throws:
MemcachedExceptionjava.lang.InterruptedException
-
flushAll
void flushAll(java.net.InetSocketAddress address, long timeout) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutException- Throws:
MemcachedExceptionjava.lang.InterruptedExceptionjava.util.concurrent.TimeoutException
-
flushAll
@Deprecated void flushAll(java.lang.String host) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedExceptionDeprecated.This method is deprecated,please use flushAll(InetSocketAddress) instead.- Parameters:
host-- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
stats
java.util.Map<java.lang.String,java.lang.String> stats(java.net.InetSocketAddress address) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutException- Throws:
MemcachedExceptionjava.lang.InterruptedExceptionjava.util.concurrent.TimeoutException
-
stats
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�ョ��瑰������emcached server缁��淇℃�- Parameters:
address- ����板�timeout- ���瓒��- Returns:
- Throws:
MemcachedExceptionjava.lang.InterruptedExceptionjava.util.concurrent.TimeoutException
-
getStats
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.TimeoutExceptionGet stats from all memcached servers- Parameters:
timeout-- Returns:
- server->item->value map
- Throws:
MemcachedExceptionjava.lang.InterruptedExceptionjava.util.concurrent.TimeoutException
-
getStats
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- Throws:
MemcachedExceptionjava.lang.InterruptedExceptionjava.util.concurrent.TimeoutException
-
getStatsByItem
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.TimeoutExceptionGet special item stats. "stats items" for example- Parameters:
item-- Returns:
- Throws:
MemcachedExceptionjava.lang.InterruptedExceptionjava.util.concurrent.TimeoutException
-
shutdown
void shutdown() throws java.io.IOException- Throws:
java.io.IOException
-
delete
boolean delete(java.lang.String key) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
getTranscoder
Transcoder getTranscoder()
return default transcoder,default is SerializingTranscoder- Returns:
-
setTranscoder
void setTranscoder(Transcoder transcoder)
set transcoder- Parameters:
transcoder-
-
getStatsByItem
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- Throws:
MemcachedExceptionjava.lang.InterruptedExceptionjava.util.concurrent.TimeoutException
-
getOpTimeout
long getOpTimeout()
get operation timeout setting- Returns:
-
setOpTimeout
void setOpTimeout(long opTimeout)
set operation timeout,default is one second.- Parameters:
opTimeout-
-
getVersions
java.util.Map<java.net.InetSocketAddress,java.lang.String> getVersions(long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
getAvaliableServers
@Deprecated java.util.Collection<java.net.InetSocketAddress> getAvaliableServers()
Deprecated.Returns available memcached servers list.This method is drepcated,please use getAvailableServers instead.- Returns:
- See Also:
getAvailableServers()
-
getAvailableServers
java.util.Collection<java.net.InetSocketAddress> getAvailableServers()
Returns available memcached servers list.- Returns:
- A available server collection
-
addServer
void addServer(java.lang.String server, int port, int weight) throws java.io.IOExceptionadd a memcached server to MemcachedClient- Parameters:
server-port-weight-- Throws:
java.io.IOException
-
addServer
void addServer(java.net.InetSocketAddress inetSocketAddress, int weight) throws java.io.IOException- Throws:
java.io.IOException
-
deleteWithNoReply
@Deprecated void deleteWithNoReply(java.lang.String key, int time) throws java.lang.InterruptedException, MemcachedExceptionDeprecated.Delete key's data item from memcached.This method doesn't wait for reply. This method does not work on memcached 1.3 or later version.See i s s u e 3 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.- Parameters:
key-time-- Throws:
java.lang.InterruptedExceptionMemcachedException
-
deleteWithNoReply
void deleteWithNoReply(java.lang.String key) throws java.lang.InterruptedException, MemcachedException- Throws:
java.lang.InterruptedExceptionMemcachedException
-
incrWithNoReply
void incrWithNoReply(java.lang.String key, long delta) throws java.lang.InterruptedException, MemcachedException"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.- Parameters:
key-num-- Throws:
java.lang.InterruptedExceptionMemcachedException
-
decrWithNoReply
void decrWithNoReply(java.lang.String key, long delta) throws java.lang.InterruptedException, MemcachedException"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.- Parameters:
key-num-- Throws:
java.lang.InterruptedExceptionMemcachedException
-
setLoggingLevelVerbosity
void setLoggingLevelVerbosity(java.net.InetSocketAddress address, int level) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedExceptionSet the verbosity level of the memcached's logging output.This method will wait for reply.- Parameters:
address-level- logging level- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
setLoggingLevelVerbosityWithNoReply
void setLoggingLevelVerbosityWithNoReply(java.net.InetSocketAddress address, int level) throws java.lang.InterruptedException, MemcachedExceptionSet the verbosity level of the memcached's logging output.This method doesn't wait for reply from server- Parameters:
address- memcached server addresslevel- logging level- Throws:
java.lang.InterruptedExceptionMemcachedException
-
addStateListener
void addStateListener(MemcachedClientStateListener listener)
Add a memcached client listener- Parameters:
listener-
-
removeStateListener
void removeStateListener(MemcachedClientStateListener listener)
Remove a memcached client listener- Parameters:
listener-
-
getStateListeners
java.util.Collection<MemcachedClientStateListener> getStateListeners()
Get all current state listeners- Returns:
-
flushAllWithNoReply
void flushAllWithNoReply(int exptime) throws java.lang.InterruptedException, MemcachedException- Throws:
java.lang.InterruptedExceptionMemcachedException
-
flushAll
void flushAll(int exptime, long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
flushAllWithNoReply
void flushAllWithNoReply(java.net.InetSocketAddress address, int exptime) throws MemcachedException, java.lang.InterruptedException- Throws:
MemcachedExceptionjava.lang.InterruptedException
-
flushAll
void flushAll(java.net.InetSocketAddress address, long timeout, int exptime) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutException- Throws:
MemcachedExceptionjava.lang.InterruptedExceptionjava.util.concurrent.TimeoutException
-
setHealSessionInterval
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. You can change that value by this method.- Parameters:
healConnectionInterval- MILLISECONDS
-
setEnableHealSession
void 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.- Parameters:
enableHealSession-- Since:
- 1.3.9
-
getHealSessionInterval
long getHealSessionInterval()
Return the default heal session interval in milliseconds- Returns:
-
getProtocol
Protocol getProtocol()
-
setPrimitiveAsString
void setPrimitiveAsString(boolean primitiveAsString)
Store all primitive type as string,defualt is false.
-
setConnectionPoolSize
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. 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.- Parameters:
poolSize- pool size,default is one,every memcached has only one connection.
-
setEnableHeartBeat
void setEnableHeartBeat(boolean enableHeartBeat)
Whether to enable heart beat- Parameters:
enableHeartBeat- if true,then enable heartbeat,true by default
-
setSanitizeKeys
void setSanitizeKeys(boolean sanitizeKey)
Enables/disables sanitizing keys by URLEncoding.- Parameters:
sanitizeKey- if true, then URLEncode all keys
-
isSanitizeKeys
boolean isSanitizeKeys()
-
getCounter
Counter getCounter(java.lang.String key)
Get counter for key,and if the key's value is not set,then set it with 0.- Parameters:
key-- Returns:
-
getCounter
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.- Parameters:
key-initialValue-- Returns:
-
getKeyIterator
@Deprecated KeyIterator getKeyIterator(java.net.InetSocketAddress address) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
Deprecated.memcached 1.6.x will remove cachedump stats command,so this method will be removed in the futureGet 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.- Parameters:
address-- Returns:
- Throws:
MemcachedExceptionjava.lang.InterruptedExceptionjava.util.concurrent.TimeoutException
-
setAuthInfoMap
void setAuthInfoMap(java.util.Map<java.net.InetSocketAddress,AuthInfo> map)
Configure auth info- Parameters:
map- Auth info map,key is memcached server address,and value is the auth info for the key.
-
getAuthInfoMap
java.util.Map<java.net.InetSocketAddress,AuthInfo> getAuthInfoMap()
return current all auth info- Returns:
- Auth info map,key is memcached server address,and value is the auth info for the key.
-
getAuthInfoStringMap
java.util.Map<java.lang.String,AuthInfo> getAuthInfoStringMap()
Retruns the AuthInfo for all server strings (hostname:port)- Returns:
- A map of AuthInfos for server strings (hostname:port)
-
decr
long decr(java.lang.String key, long delta, long initValue, long timeout, int exp) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException"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.- Parameters:
key-delta-initValue- the initial value to be added when value is not foundtimeout-exp- the initial vlaue expire time, in seconds. Can be up to 30 days. After 30 days, is treated as a unix timestamp of an exact date.- Returns:
- Throws:
java.util.concurrent.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
incr
long incr(java.lang.String key, long delta, long initValue, long timeout, int exp) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException"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.- 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.TimeoutExceptionjava.lang.InterruptedExceptionMemcachedException
-
getName
java.lang.String getName()
Return the cache instance name- Returns:
-
setName
void setName(java.lang.String name)
Set cache instance name- Parameters:
name-
-
getReconnectRequestQueue
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.- Returns:
- The reconnecting task queue,if the client has not been started,returns null.
-
setFailureMode
void 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. 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.- Parameters:
failureMode- true is to configure client in failure mode.
-
isFailureMode
boolean isFailureMode()
Returns if client is in failure mode.- Returns:
-
setKeyProvider
void setKeyProvider(KeyProvider keyProvider)
Set a key provider for pre-processing keys before sending them to memcached.- Parameters:
keyProvider-- Since:
- 1.3.8
-
getTimeoutExceptionThreshold
int getTimeoutExceptionThreshold()
Returns maximum number of timeout exception for closing connection.- Returns:
-
setTimeoutExceptionThreshold
void 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.- Parameters:
timeoutExceptionThreshold-- See Also:
DEFAULT_MAX_TIMEOUTEXCEPTION_THRESHOLD
-
invalidateNamespace
void invalidateNamespace(java.lang.String ns) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutExceptionInvalidate all namespace under the namespace using the default operation timeout.- Parameters:
ns- the namespace- Throws:
MemcachedExceptionjava.lang.InterruptedExceptionjava.util.concurrent.TimeoutException- Since:
- 1.4.2
-
invalidateNamespace
void invalidateNamespace(java.lang.String ns, long opTimeout) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutExceptionInvalidate all items under the namespace.- Parameters:
ns- the namespaceopTimeout- operation timeout in milliseconds.- Throws:
MemcachedExceptionjava.lang.InterruptedExceptionjava.util.concurrent.TimeoutException- Since:
- 1.4.2
-
endWithNamespace
void endWithNamespace()
Remove current namespace set for this memcached client.It must begin withbeginWithNamespace(String)method.- See Also:
beginWithNamespace(String)
-
beginWithNamespace
void beginWithNamespace(java.lang.String ns)
set current namespace for following operations with memcached client.It must be ended withendWithNamespace()method.For example:memcachedClient.beginWithNamespace(userId); try { memcachedClient.set("username", 0, username); memcachedClient.set("email", 0, email); } finally { memcachedClient.endWithNamespace(); }- Parameters:
ns-- See Also:
endWithNamespace(),withNamespace(String, MemcachedClientCallable)
-
withNamespace
<T> T withNamespace(java.lang.String ns, MemcachedClientCallable<T> callable) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutExceptionWith the namespae to do something with current memcached client.All operations with memcached client done in callable will be under the namespace.beginWithNamespace(String)andendWithNamespace()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); - Parameters:
ns-callable-- Returns:
- Throws:
MemcachedExceptionjava.lang.InterruptedExceptionjava.util.concurrent.TimeoutException- Since:
- 1.4.2
- See Also:
beginWithNamespace(String),endWithNamespace()
-
-