Package net.rubyeye.xmemcached
Interface MemcachedClient
-
- All Known Implementing Classes:
AWSElasticCacheClient
,XMemcachedClient
public interface MemcachedClient
The memcached client's interface
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_CONNECT_TIMEOUT
Default connect timeout,1 minutesstatic 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.static long
DEFAULT_HEAL_SESSION_INTERVAL
Default heal session interval in milliseconds.static int
DEFAULT_MAX_QUEUED_NOPS
Default max queued noreply operations number.It is calcuated dynamically based on your jvm maximum memory.static int
DEFAULT_MAX_TIMEOUTEXCEPTION_THRESHOLD
Maximum number of timeout exception for close connection.static long
DEFAULT_OP_TIMEOUT
Default operation timeout,if the operation is not returned in 5 second,throw TimeoutException.static 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.static 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.static int
DEFAULT_SESSION_READ_BUFF_SIZE
Default session read buffer size,16kstatic boolean
DEFAULT_TCP_KEEPLIVE
Default TCP keeplive option,which is truestatic boolean
DEFAULT_TCP_NO_DELAY
Disable nagle algorithm by defaultstatic int
DEFAULT_TCP_RECV_BUFF_SIZE
Default socket's receive buffer size,16kstatic int
DEFAULT_TCP_SEND_BUFF_SIZE
Default socket's send buffer size,8kstatic int
DYNAMIC_MAX_QUEUED_NOPS
static int
MAX_QUEUED_NOPS
-
Method Summary
All Methods Instance Methods Abstract 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.void
addServer(java.lang.String hostList)
Add many memcached servers.You can call this method through JMX or programvoid
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 withendWithNamespace()
method.For example: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> getsResponse, CASOperation<T> operation)
<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)
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)
Deprecated.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.void
deleteWithNoReply(java.lang.String key)
void
deleteWithNoReply(java.lang.String key, int time)
Deprecated.void
endWithNamespace()
Remove current namespace set for this memcached client.It must begin withbeginWithNamespace(String)
method.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)
Deprecated.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)
void
flushAllWithNoReply()
void
flushAllWithNoReply(int exptime)
void
flushAllWithNoReply(java.net.InetSocketAddress address)
void
flushAllWithNoReply(java.net.InetSocketAddress address, 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 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> 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.Connector
getConnector()
return the session managerlong
getConnectTimeout()
Get the connect timeoutCounter
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 futurejava.lang.String
getName()
Return the cache instance namelong
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 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)
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()
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.void
removeServer(java.lang.String hostList)
Remove many memcached servervoid
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)
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)
Deprecated.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 servervoid
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 sanitizeKey)
Enables/disables sanitizing keys by URLEncoding.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.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()
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
-
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.IOException
Aadd 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.IOException
Add 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.IOException
Add 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, MemcachedException
Get 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.TimeoutException
java.lang.InterruptedException
MemcachedException
-
get
<T> T get(java.lang.String key, long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
get
<T> T get(java.lang.String key, Transcoder<T> transcoder) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
get
<T> T get(java.lang.String key) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
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.TimeoutException
java.lang.InterruptedException
MemcachedException
-
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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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, MemcachedException
Bulk get items- Type Parameters:
T
-- Parameters:
keyCollections
- key collectionopTimeout
- opTimeouttranscoder
- Value transcoder- Returns:
- Exists items map
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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, MemcachedException
Store 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.TimeoutException
java.lang.InterruptedException
MemcachedException
-
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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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, MemcachedException
Store 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.TimeoutException
java.lang.InterruptedException
MemcachedException
-
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.InterruptedException
MemcachedException
- 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, MemcachedException
Add 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.TimeoutException
java.lang.InterruptedException
MemcachedException
-
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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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, MemcachedException
Add 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.TimeoutException
java.lang.InterruptedException
MemcachedException
-
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.InterruptedException
MemcachedException
- 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, MemcachedException
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.- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
-
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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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, MemcachedException
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.- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
-
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.InterruptedException
MemcachedException
- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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, MemcachedException
Append value to key's data item,this method will wait for reply- Parameters:
key
-value
-timeout
-- Returns:
- boolean result
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
appendWithNoReply
void appendWithNoReply(java.lang.String key, java.lang.Object value) throws java.lang.InterruptedException, MemcachedException
Append value to key's data item,this method doesn't wait for reply.- Parameters:
key
-value
-- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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, MemcachedException
Prepend 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.TimeoutException
java.lang.InterruptedException
MemcachedException
-
prependWithNoReply
void prependWithNoReply(java.lang.String key, java.lang.Object value) throws java.lang.InterruptedException, MemcachedException
Prepend value to key's data item in memcached.This method doesn't wait for reply.- Parameters:
key
-value
-- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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, MemcachedException
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."- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
-
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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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, MemcachedException
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."- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
-
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, MemcachedException
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."- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
-
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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
-
casWithNoReply
<T> void casWithNoReply(java.lang.String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
cas noreply- Type Parameters:
T
-- Parameters:
key
-exp
-getsReponse
-operation
-- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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, MemcachedException
Deprecated.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.InterruptedException
MemcachedException
java.util.concurrent.TimeoutException
-
delete
boolean delete(java.lang.String key, long opTimeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
Delete key's date item from memcached- Parameters:
key
-opTimeout
- Operation timeout- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
- Since:
- 1.3.2
-
delete
boolean delete(java.lang.String key, long cas, long opTimeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
Delete 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.TimeoutException
java.lang.InterruptedException
MemcachedException
- Since:
- 1.3.2
-
touch
boolean touch(java.lang.String key, int exp, long opTimeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
Set 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.TimeoutException
java.lang.InterruptedException
MemcachedException
-
touch
boolean touch(java.lang.String key, int exp) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
Set 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.TimeoutException
java.lang.InterruptedException
MemcachedException
-
getAndTouch
<T> T getAndTouch(java.lang.String key, int newExp, long opTimeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
Get 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.TimeoutException
java.lang.InterruptedException
MemcachedException
-
getAndTouch
<T> T getAndTouch(java.lang.String key, int newExp) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
Get item and set a new expiration time for it,using default opTimeout- Type Parameters:
T
-- Parameters:
key
-newExp
-- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
getVersions
java.util.Map<java.net.InetSocketAddress,java.lang.String> getVersions() throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
Get all connected memcached servers's version.- Returns:
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
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.InterruptedException
MemcachedException
java.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.TimeoutException
java.lang.InterruptedException
MemcachedException
-
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.TimeoutException
java.lang.InterruptedException
MemcachedException
-
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.InterruptedException
MemcachedException
java.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.TimeoutException
java.lang.InterruptedException
MemcachedException
- 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.TimeoutException
java.lang.InterruptedException
MemcachedException
-
flushAll
void flushAll() throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
Make All connected memcached's data item invalid- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
flushAllWithNoReply
void flushAllWithNoReply() throws java.lang.InterruptedException, MemcachedException
- Throws:
java.lang.InterruptedException
MemcachedException
-
flushAll
void flushAll(long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
Make All connected memcached's data item invalid- Parameters:
timeout
- operation timeout- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
flushAll
void flushAll(java.net.InetSocketAddress address) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
Invalidate all existing items immediately- Parameters:
address
- Target memcached servertimeout
- operation timeout- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
flushAllWithNoReply
void flushAllWithNoReply(java.net.InetSocketAddress address) throws MemcachedException, java.lang.InterruptedException
- Throws:
MemcachedException
java.lang.InterruptedException
-
flushAll
void flushAll(java.net.InetSocketAddress address, long timeout) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
- Throws:
MemcachedException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
-
flushAll
@Deprecated void flushAll(java.lang.String host) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
Deprecated.This method is deprecated,please use flushAll(InetSocketAddress) instead.- Parameters:
host
-- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
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:
MemcachedException
java.lang.InterruptedException
java.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:
MemcachedException
java.lang.InterruptedException
java.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.TimeoutException
Get stats from all memcached servers- Parameters:
timeout
-- Returns:
- server->item->value map
- Throws:
MemcachedException
java.lang.InterruptedException
java.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:
MemcachedException
java.lang.InterruptedException
java.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.TimeoutException
Get special item stats. "stats items" for example- Parameters:
item
-- Returns:
- Throws:
MemcachedException
java.lang.InterruptedException
java.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.TimeoutException
java.lang.InterruptedException
MemcachedException
-
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:
MemcachedException
java.lang.InterruptedException
java.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.TimeoutException
java.lang.InterruptedException
MemcachedException
-
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.IOException
add 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, MemcachedException
Deprecated.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.InterruptedException
MemcachedException
-
deleteWithNoReply
void deleteWithNoReply(java.lang.String key) throws java.lang.InterruptedException, MemcachedException
- Throws:
java.lang.InterruptedException
MemcachedException
-
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.InterruptedException
MemcachedException
-
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.InterruptedException
MemcachedException
-
setLoggingLevelVerbosity
void setLoggingLevelVerbosity(java.net.InetSocketAddress address, int level) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
Set the verbosity level of the memcached's logging output.This method will wait for reply.- Parameters:
address
-level
- logging level- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
setLoggingLevelVerbosityWithNoReply
void setLoggingLevelVerbosityWithNoReply(java.net.InetSocketAddress address, int level) throws java.lang.InterruptedException, MemcachedException
Set 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.InterruptedException
MemcachedException
-
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.InterruptedException
MemcachedException
-
flushAll
void flushAll(int exptime, long timeout) throws java.util.concurrent.TimeoutException, java.lang.InterruptedException, MemcachedException
- Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException
MemcachedException
-
flushAllWithNoReply
void flushAllWithNoReply(java.net.InetSocketAddress address, int exptime) throws MemcachedException, java.lang.InterruptedException
- Throws:
MemcachedException
java.lang.InterruptedException
-
flushAll
void flushAll(java.net.InetSocketAddress address, long timeout, int exptime) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
- Throws:
MemcachedException
java.lang.InterruptedException
java.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:
MemcachedException
java.lang.InterruptedException
java.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.TimeoutException
java.lang.InterruptedException
MemcachedException
-
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.TimeoutException
java.lang.InterruptedException
MemcachedException
-
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.TimeoutException
Invalidate all namespace under the namespace using the default operation timeout.- Parameters:
ns
- the namespace- Throws:
MemcachedException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
- Since:
- 1.4.2
-
invalidateNamespace
void invalidateNamespace(java.lang.String ns, long opTimeout) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
Invalidate all items under the namespace.- Parameters:
ns
- the namespaceopTimeout
- operation timeout in milliseconds.- Throws:
MemcachedException
java.lang.InterruptedException
java.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.TimeoutException
With 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:
MemcachedException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
- Since:
- 1.4.2
- See Also:
beginWithNamespace(String)
,endWithNamespace()
-
-