public interface MemcachedClient
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
DEFAULT_CONNECT_TIMEOUT
Default connect timeout,1 minutes
|
static 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,16k
|
static boolean |
DEFAULT_TCP_KEEPLIVE
Default TCP keeplive option,which is true
|
static boolean |
DEFAULT_TCP_NO_DELAY
Disable nagle algorithm by default
|
static int |
DEFAULT_TCP_RECV_BUFF_SIZE
Default socket's receive buffer size,16k
|
static int |
DEFAULT_TCP_SEND_BUFF_SIZE
Default socket's send buffer size,8k
|
static int |
DYNAMIC_MAX_QUEUED_NOPS |
static int |
MAX_QUEUED_NOPS |
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
add(String key,
int exp,
Object value) |
boolean |
add(String key,
int exp,
Object value,
long timeout) |
<T> boolean |
add(String key,
int exp,
T value,
Transcoder<T> transcoder) |
<T> boolean |
add(String key,
int exp,
T value,
Transcoder<T> transcoder,
long timeout)
Add key-value item to memcached, success only when the key is not exists
in memcached.
|
void |
addServer(InetSocketAddress inetSocketAddress)
Add a memcached server,the thread call this method will be blocked until
the connecting operations completed(success or fail)
|
void |
addServer(InetSocketAddress inetSocketAddress,
int weight) |
void |
addServer(String hostList)
Add many memcached servers.You can call this method through JMX or
program
|
void |
addServer(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(String server,
int port,
int weight)
add a memcached server to MemcachedClient
|
void |
addStateListener(MemcachedClientStateListener listener)
Add a memcached client listener
|
void |
addWithNoReply(String key,
int exp,
Object value)
Add key-value item to memcached, success only when the key is not exists
in memcached.This method doesn't wait for reply.
|
<T> void |
addWithNoReply(String key,
int exp,
T value,
Transcoder<T> transcoder) |
boolean |
append(String key,
Object value) |
boolean |
append(String key,
Object value,
long timeout)
Append value to key's data item,this method will wait for reply
|
void |
appendWithNoReply(String key,
Object value)
Append value to key's data item,this method doesn't wait for reply.
|
void |
beginWithNamespace(String ns)
set current namespace for following operations with memcached client.It
must be ended with
endWithNamespace() method.For example:
memcachedClient.beginWithNamespace(userId);
try{
memcachedClient.set("username",0,username);
memcachedClient.set("email",0,email);
}finally{
memcachedClient.endWithNamespace();
}
|
<T> boolean |
cas(String key,
CASOperation<T> operation) |
<T> boolean |
cas(String key,
GetsResponse<T> getsResponse,
CASOperation<T> operation) |
<T> boolean |
cas(String key,
int exp,
CASOperation<T> operation) |
<T> boolean |
cas(String key,
int exp,
CASOperation<T> operation,
Transcoder<T> transcoder)
Cas is a check and set operation which means "store this data but only if
no one else has updated since I last fetched it."
|
<T> boolean |
cas(String key,
int exp,
GetsResponse<T> getsReponse,
CASOperation<T> operation) |
<T> boolean |
cas(String key,
int exp,
GetsResponse<T> getsReponse,
CASOperation<T> operation,
Transcoder<T> transcoder)
cas is a check and set operation which means "store this data but only if
no one else has updated since I last fetched it."
|
boolean |
cas(String key,
int exp,
Object value,
long cas) |
boolean |
cas(String key,
int exp,
Object value,
long timeout,
long cas) |
<T> boolean |
cas(String key,
int exp,
T value,
Transcoder<T> transcoder,
long cas) |
<T> boolean |
cas(String key,
int exp,
T value,
Transcoder<T> transcoder,
long timeout,
long cas)
Cas is a check and set operation which means "store this data but only if
no one else has updated since I last fetched it."
|
<T> void |
casWithNoReply(String key,
CASOperation<T> operation) |
<T> void |
casWithNoReply(String key,
GetsResponse<T> getsResponse,
CASOperation<T> operation) |
<T> void |
casWithNoReply(String key,
int exp,
CASOperation<T> operation) |
<T> void |
casWithNoReply(String key,
int exp,
GetsResponse<T> getsReponse,
CASOperation<T> operation)
cas noreply
|
long |
decr(String key,
long delta)
"decr" are used to change data for some item in-place, decrementing it.
|
long |
decr(String key,
long delta,
long initValue) |
long |
decr(String key,
long delta,
long initValue,
long timeout)
"decr" are used to change data for some item in-place, decrementing it.
|
long |
decr(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(String key,
long delta)
"decr" are used to change data for some item in-place, decrementing it.
|
boolean |
delete(String key) |
boolean |
delete(String key,
int time)
已过时。
|
boolean |
delete(String key,
long opTimeout)
Delete key's date item from memcached
|
boolean |
delete(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(String key) |
void |
deleteWithNoReply(String key,
int time)
已过时。
|
void |
endWithNamespace()
Remove current namespace set for this memcached client.It must begin with
beginWithNamespace(String) method. |
void |
flushAll()
Make All connected memcached's data item invalid
|
void |
flushAll(InetSocketAddress address)
Invalidate all existing items immediately
|
void |
flushAll(InetSocketAddress address,
long timeout) |
void |
flushAll(InetSocketAddress address,
long timeout,
int exptime) |
void |
flushAll(int exptime,
long timeout) |
void |
flushAll(long timeout)
Make All connected memcached's data item invalid
|
void |
flushAll(String host)
已过时。
|
void |
flushAllWithNoReply() |
void |
flushAllWithNoReply(InetSocketAddress address) |
void |
flushAllWithNoReply(InetSocketAddress address,
int exptime) |
void |
flushAllWithNoReply(int exptime) |
<T> Map<String,T> |
get(Collection<String> keyCollections) |
<T> Map<String,T> |
get(Collection<String> keyCollections,
long timeout) |
<T> Map<String,T> |
get(Collection<String> keyCollections,
long opTimeout,
Transcoder<T> transcoder)
Bulk get items
|
<T> Map<String,T> |
get(Collection<String> keyCollections,
Transcoder<T> transcoder) |
<T> T |
get(String key) |
<T> T |
get(String key,
long timeout) |
<T> T |
get(String key,
long timeout,
Transcoder<T> transcoder)
Get value by key
|
<T> T |
get(String key,
Transcoder<T> transcoder) |
<T> T |
getAndTouch(String key,
int newExp)
Get item and set a new expiration time for it,using default opTimeout
|
<T> T |
getAndTouch(String key,
int newExp,
long opTimeout)
Get item and set a new expiration time for it
|
Map<InetSocketAddress,AuthInfo> |
getAuthInfoMap()
return current all auth info
|
Collection<InetSocketAddress> |
getAvailableServers()
Returns available memcached servers list.
|
Collection<InetSocketAddress> |
getAvaliableServers()
已过时。
|
Connector |
getConnector()
return the session manager
|
long |
getConnectTimeout()
Get the connect timeout
|
Counter |
getCounter(String key)
Get counter for key,and if the key's value is not set,then set it with 0.
|
Counter |
getCounter(String key,
long initialValue)
Get counter for key,and if the key's value is not set,then set it with
initial value.
|
long |
getHealSessionInterval()
Return the default heal session interval in milliseconds
|
KeyIterator |
getKeyIterator(InetSocketAddress address)
已过时。
memcached 1.6.x will remove cachedump stats command,so this
method will be removed in the future
|
String |
getName()
Return the cache instance name
|
long |
getOpTimeout()
get operation timeout setting
|
Protocol |
getProtocol() |
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> Map<String,GetsResponse<T>> |
gets(Collection<String> keyCollections) |
<T> Map<String,GetsResponse<T>> |
gets(Collection<String> keyCollections,
long timeout) |
<T> Map<String,GetsResponse<T>> |
gets(Collection<String> keyCollections,
long opTime,
Transcoder<T> transcoder)
Bulk gets items
|
<T> Map<String,GetsResponse<T>> |
gets(Collection<String> keyCollections,
Transcoder<T> transcoder) |
<T> GetsResponse<T> |
gets(String key) |
<T> GetsResponse<T> |
gets(String key,
long timeout) |
<T> GetsResponse<T> |
gets(String key,
long timeout,
Transcoder<T> transcoder)
Just like get,But it return a GetsResponse,include cas value for cas
update.
|
<T> GetsResponse<T> |
gets(String key,
Transcoder transcoder) |
List<String> |
getServersDescription()
Get current server list.You can call this method through JMX or program
|
Collection<MemcachedClientStateListener> |
getStateListeners()
Get all current state listeners
|
Map<InetSocketAddress,Map<String,String>> |
getStats() |
Map<InetSocketAddress,Map<String,String>> |
getStats(long timeout)
Get stats from all memcached servers
|
Map<InetSocketAddress,Map<String,String>> |
getStatsByItem(String itemName)
Get special item stats.
|
Map<InetSocketAddress,Map<String,String>> |
getStatsByItem(String itemName,
long timeout) |
int |
getTimeoutExceptionThreshold()
Returns maximum number of timeout exception for closing connection.
|
Transcoder |
getTranscoder()
return default transcoder,default is SerializingTranscoder
|
Map<InetSocketAddress,String> |
getVersions()
Get all connected memcached servers's version.
|
Map<InetSocketAddress,String> |
getVersions(long timeout) |
long |
incr(String key,
long delta)
"incr" are used to change data for some item in-place, incrementing it.
|
long |
incr(String key,
long delta,
long initValue) |
long |
incr(String key,
long delta,
long initValue,
long timeout)
"incr" are used to change data for some item in-place, incrementing it.
|
long |
incr(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(String key,
long delta)
"incr" are used to change data for some item in-place, incrementing it.
|
void |
invalidateNamespace(String ns)
Invalidate all namespace under the namespace using the default operation
timeout.
|
void |
invalidateNamespace(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(String key,
Object value) |
boolean |
prepend(String key,
Object value,
long timeout)
Prepend value to key's data item in memcached.This method doesn't wait
for reply.
|
void |
prependWithNoReply(String key,
Object value)
Prepend value to key's data item in memcached.This method doesn't wait
for reply.
|
void |
removeServer(String hostList)
Remove many memcached server
|
void |
removeStateListener(MemcachedClientStateListener listener)
Remove a memcached client listener
|
boolean |
replace(String key,
int exp,
Object value) |
boolean |
replace(String key,
int exp,
Object value,
long timeout) |
<T> boolean |
replace(String key,
int exp,
T value,
Transcoder<T> transcoder) |
<T> boolean |
replace(String key,
int exp,
T value,
Transcoder<T> transcoder,
long timeout)
Replace the key's data item in memcached,success only when the key's data
item is exists in memcached.This method will wait for reply from server.
|
void |
replaceWithNoReply(String key,
int exp,
Object value)
Replace the key's data item in memcached,success only when the key's data
item is exists in memcached.This method doesn't wait for reply from
server.
|
<T> void |
replaceWithNoReply(String key,
int exp,
T value,
Transcoder<T> transcoder) |
boolean |
set(String key,
int exp,
Object value) |
boolean |
set(String key,
int exp,
Object value,
long timeout) |
<T> boolean |
set(String key,
int exp,
T value,
Transcoder<T> transcoder) |
<T> boolean |
set(String key,
int exp,
T value,
Transcoder<T> transcoder,
long timeout)
Store key-value item to memcached
|
void |
setAuthInfoMap(Map<InetSocketAddress,AuthInfo> map)
Configure auth info
|
void |
setBufferAllocator(BufferAllocator bufferAllocator)
已过时。
|
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 minutes
|
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. |
void |
setEnableHeartBeat(boolean enableHeartBeat)
Whether to enable heart beat
|
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.
|
void |
setHealSessionInterval(long healConnectionInterval)
If the memcached dump or network error cause connection closed,xmemcached
would try to heal the connection.The interval between reconnections is 2
seconds by default.
|
void |
setKeyProvider(KeyProvider keyProvider)
Set a key provider for pre-processing keys before sending them to
memcached.
|
void |
setLoggingLevelVerbosity(InetSocketAddress address,
int level)
Set the verbosity level of the memcached's logging output.This method
will wait for reply.
|
void |
setLoggingLevelVerbosityWithNoReply(InetSocketAddress address,
int level)
Set the verbosity level of the memcached's logging output.This method
doesn't wait for reply from server
|
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
|
void |
setName(String name)
Set cache instance name
|
void |
setOpTimeout(long opTimeout)
set operation timeout,default is one second.
|
void |
setOptimizeGet(boolean optimizeGet)
Enable/Disable merge many get commands to one multi-get command.true is
to enable it,false is to disable it.Default is true.Recommend users to
enable it.
|
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 transcoder
|
void |
setWithNoReply(String key,
int exp,
Object value)
Store key-value item to memcached,doesn't wait for reply
|
<T> void |
setWithNoReply(String key,
int exp,
T value,
Transcoder<T> transcoder) |
void |
shutdown() |
Map<String,String> |
stats(InetSocketAddress address) |
Map<String,String> |
stats(InetSocketAddress address,
long timeout)
�ョ��瑰������emcached server缁��淇℃�
|
boolean |
touch(String key,
int exp)
Set a new expiration time for an existing item,using default opTimeout
second.
|
boolean |
touch(String key,
int exp,
long opTimeout)
Set a new expiration time for an existing item
|
<T> T |
withNamespace(String ns,
MemcachedClientCallable<T> callable)
With the namespae to do something with current memcached client.All
operations with memcached client done in callable will be under the
namespace.
|
static final int DEFAULT_READ_THREAD_COUNT
static final boolean DEFAULT_TCP_KEEPLIVE
static final int DEFAULT_CONNECT_TIMEOUT
static final int DEFAULT_TCP_SEND_BUFF_SIZE
static final boolean DEFAULT_TCP_NO_DELAY
static final int DEFAULT_SESSION_READ_BUFF_SIZE
static final int DEFAULT_TCP_RECV_BUFF_SIZE
static final long DEFAULT_OP_TIMEOUT
static final int DEFAULT_CONNECTION_POOL_SIZE
static final int DEFAULT_SESSION_IDLE_TIMEOUT
static final long DEFAULT_HEAL_SESSION_INTERVAL
static final int MAX_QUEUED_NOPS
static final int DYNAMIC_MAX_QUEUED_NOPS
static final int DEFAULT_MAX_QUEUED_NOPS
static final int DEFAULT_MAX_TIMEOUTEXCEPTION_THRESHOLD
void setMergeFactor(int mergeFactor)
mergeFactor - long getConnectTimeout()
void setConnectTimeout(long connectTimeout)
connectTimeout - Connector getConnector()
void setOptimizeGet(boolean optimizeGet)
optimizeGet - void setOptimizeMergeBuffer(boolean optimizeMergeBuffer)
optimizeMergeBuffer - boolean isShutdown()
void addServer(String server, int port) throws IOException
server - host stringport - port numberIOExceptionvoid addServer(InetSocketAddress inetSocketAddress) throws IOException
inetSocketAddress - memcached server's socket addressIOExceptionvoid addServer(String hostList) throws IOException
host - String like [host1]:[port1] [host2]:[port2] ...IOExceptionList<String> getServersDescription()
void removeServer(String hostList)
host - String like [host1]:[port1] [host2]:[port2] ...@Deprecated void setBufferAllocator(BufferAllocator bufferAllocator)
bufferAllocator - <T> T get(String key, long timeout, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException
T - key - Keytimeout - Operation timeout,if the method is not returned in this
time,throw TimeoutExceptiontranscoder - The value's transcoderTimeoutExceptionInterruptedExceptionMemcachedException<T> T get(String key, long timeout) throws TimeoutException, InterruptedException, MemcachedException
<T> T get(String key, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException
<T> T get(String key) throws TimeoutException, InterruptedException, MemcachedException
<T> GetsResponse<T> gets(String key, long timeout, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException
T - key - keytimeout - operation timeouttranscoder - TimeoutExceptionInterruptedExceptionMemcachedException<T> GetsResponse<T> gets(String key) throws TimeoutException, InterruptedException, MemcachedException
T - key - TimeoutExceptionInterruptedExceptionMemcachedExceptiongets(String, long, Transcoder)<T> GetsResponse<T> gets(String key, long timeout) throws TimeoutException, InterruptedException, MemcachedException
T - key - timeout - TimeoutExceptionInterruptedExceptionMemcachedExceptiongets(String, long, Transcoder)<T> GetsResponse<T> gets(String key, Transcoder transcoder) throws TimeoutException, InterruptedException, MemcachedException
T - key - transcoder - TimeoutExceptionInterruptedExceptionMemcachedExceptiongets(String, long, Transcoder)<T> Map<String,T> get(Collection<String> keyCollections, long opTimeout, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException
T - keyCollections - key collectionopTimeout - opTimeouttranscoder - Value transcoderTimeoutExceptionInterruptedExceptionMemcachedException<T> Map<String,T> get(Collection<String> keyCollections, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException
T - keyCollections - transcoder - TimeoutExceptionInterruptedExceptionMemcachedExceptionget(Collection, long, Transcoder)<T> Map<String,T> get(Collection<String> keyCollections) throws TimeoutException, InterruptedException, MemcachedException
T - keyCollections - TimeoutExceptionInterruptedExceptionMemcachedExceptionget(Collection, long, Transcoder)<T> Map<String,T> get(Collection<String> keyCollections, long timeout) throws TimeoutException, InterruptedException, MemcachedException
T - keyCollections - timeout - TimeoutExceptionInterruptedExceptionMemcachedExceptionget(Collection, long, Transcoder)<T> Map<String,GetsResponse<T>> gets(Collection<String> keyCollections, long opTime, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException
T - keyCollections - key collectionopTime - Operation timeouttranscoder - Value transcoderTimeoutExceptionInterruptedExceptionMemcachedExceptionGetsResponse<T> Map<String,GetsResponse<T>> gets(Collection<String> keyCollections) throws TimeoutException, InterruptedException, MemcachedException
T - keyCollections - TimeoutExceptionInterruptedExceptionMemcachedExceptiongets(Collection, long, Transcoder)<T> Map<String,GetsResponse<T>> gets(Collection<String> keyCollections, long timeout) throws TimeoutException, InterruptedException, MemcachedException
T - keyCollections - timeout - TimeoutExceptionInterruptedExceptionMemcachedExceptiongets(Collection, long, Transcoder)<T> Map<String,GetsResponse<T>> gets(Collection<String> keyCollections, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException
T - keyCollections - transcoder - TimeoutExceptionInterruptedExceptionMemcachedExceptiongets(Collection, long, Transcoder)<T> boolean set(String key, int exp, T value, Transcoder<T> transcoder, long timeout) throws TimeoutException, InterruptedException, MemcachedException
T - 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 millisecondsTimeoutExceptionInterruptedExceptionMemcachedExceptionboolean set(String key, int exp, Object value) throws TimeoutException, InterruptedException, MemcachedException
boolean set(String key, int exp, Object value, long timeout) throws TimeoutException, InterruptedException, MemcachedException
<T> boolean set(String key, int exp, T value, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException
void setWithNoReply(String key, int exp, Object value) throws InterruptedException, MemcachedException
T - 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 - transocderTimeoutExceptionInterruptedExceptionMemcachedException<T> void setWithNoReply(String key, int exp, T value, Transcoder<T> transcoder) throws InterruptedException, MemcachedException
T - key - exp - value - transcoder - InterruptedExceptionMemcachedExceptionsetWithNoReply(String, int, Object, Transcoder)<T> boolean add(String key, int exp, T value, Transcoder<T> transcoder, long timeout) throws TimeoutException, InterruptedException, MemcachedException
T - 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 - TimeoutExceptionInterruptedExceptionMemcachedExceptionboolean add(String key, int exp, Object value) throws TimeoutException, InterruptedException, MemcachedException
key - exp - value - TimeoutExceptionInterruptedExceptionMemcachedExceptionadd(String, int, Object, Transcoder, long)boolean add(String key, int exp, Object value, long timeout) throws TimeoutException, InterruptedException, MemcachedException
key - exp - value - timeout - TimeoutExceptionInterruptedExceptionMemcachedExceptionadd(String, int, Object, Transcoder, long)<T> boolean add(String key, int exp, T value, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException
T - key - exp - value - transcoder - TimeoutExceptionInterruptedExceptionMemcachedExceptionadd(String, int, Object, Transcoder, long)void addWithNoReply(String key, int exp, Object value) throws InterruptedException, MemcachedException
T - 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 - TimeoutExceptionInterruptedExceptionMemcachedException<T> void addWithNoReply(String key, int exp, T value, Transcoder<T> transcoder) throws InterruptedException, MemcachedException
T - key - exp - value - transcoder - InterruptedExceptionMemcachedExceptionaddWithNoReply(String, int, Object, Transcoder)<T> boolean replace(String key, int exp, T value, Transcoder<T> transcoder, long timeout) throws TimeoutException, InterruptedException, MemcachedException
T - 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 - TimeoutExceptionInterruptedExceptionMemcachedExceptionboolean replace(String key, int exp, Object value) throws TimeoutException, InterruptedException, MemcachedException
key - exp - value - TimeoutExceptionInterruptedExceptionMemcachedExceptionreplace(String, int, Object, Transcoder, long)boolean replace(String key, int exp, Object value, long timeout) throws TimeoutException, InterruptedException, MemcachedException
key - exp - value - timeout - TimeoutExceptionInterruptedExceptionMemcachedExceptionreplace(String, int, Object, Transcoder, long)<T> boolean replace(String key, int exp, T value, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException
T - key - exp - value - transcoder - TimeoutExceptionInterruptedExceptionMemcachedExceptionreplace(String, int, Object, Transcoder, long)void replaceWithNoReply(String key, int exp, Object value) throws InterruptedException, MemcachedException
T - 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 - TimeoutExceptionInterruptedExceptionMemcachedException<T> void replaceWithNoReply(String key, int exp, T value, Transcoder<T> transcoder) throws InterruptedException, MemcachedException
T - key - exp - value - transcoder - InterruptedExceptionMemcachedExceptionreplaceWithNoReply(String, int, Object, Transcoder)boolean append(String key, Object value) throws TimeoutException, InterruptedException, MemcachedException
key - value - TimeoutExceptionInterruptedExceptionMemcachedExceptionappend(String, Object, long)boolean append(String key, Object value, long timeout) throws TimeoutException, InterruptedException, MemcachedException
key - value - timeout - TimeoutExceptionInterruptedExceptionMemcachedExceptionvoid appendWithNoReply(String key, Object value) throws InterruptedException, MemcachedException
key - value - TimeoutExceptionInterruptedExceptionMemcachedExceptionboolean prepend(String key, Object value) throws TimeoutException, InterruptedException, MemcachedException
key - value - TimeoutExceptionInterruptedExceptionMemcachedExceptionprepend(String, Object, long)boolean prepend(String key, Object value, long timeout) throws TimeoutException, InterruptedException, MemcachedException
key - value - TimeoutExceptionInterruptedExceptionMemcachedExceptionvoid prependWithNoReply(String key, Object value) throws InterruptedException, MemcachedException
key - value - TimeoutExceptionInterruptedExceptionMemcachedExceptionboolean cas(String key, int exp, Object value, long cas) throws TimeoutException, InterruptedException, MemcachedException
key - exp - value - cas - TimeoutExceptionInterruptedExceptionMemcachedExceptioncas(String, int, Object, Transcoder, long, long)<T> boolean cas(String key, int exp, T value, Transcoder<T> transcoder, long timeout, long cas) throws TimeoutException, InterruptedException, MemcachedException
T - 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 - TimeoutExceptionInterruptedExceptionMemcachedExceptionboolean cas(String key, int exp, Object value, long timeout, long cas) throws TimeoutException, InterruptedException, MemcachedException
key - exp - value - timeout - cas - TimeoutExceptionInterruptedExceptionMemcachedExceptioncas(String, int, Object, Transcoder, long, long)<T> boolean cas(String key, int exp, T value, Transcoder<T> transcoder, long cas) throws TimeoutException, InterruptedException, MemcachedException
T - key - exp - value - transcoder - cas - TimeoutExceptionInterruptedExceptionMemcachedExceptioncas(String, int, Object, Transcoder, long, long)<T> boolean cas(String key, int exp, CASOperation<T> operation, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException
T - 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 transcoderTimeoutExceptionInterruptedExceptionMemcachedException<T> boolean cas(String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException
T - 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 - TimeoutExceptionInterruptedExceptionMemcachedException<T> boolean cas(String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException
T - key - exp - getsReponse - operation - TimeoutExceptionInterruptedExceptionMemcachedExceptioncas(String, int, GetsResponse, CASOperation, Transcoder)<T> boolean cas(String key, GetsResponse<T> getsResponse, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException
T - key - getsResponse - operation - TimeoutExceptionInterruptedExceptionMemcachedExceptioncas(String, int, GetsResponse, CASOperation, Transcoder)<T> boolean cas(String key, int exp, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException
T - key - exp - operation - TimeoutExceptionInterruptedExceptionMemcachedExceptioncas(String, int, GetsResponse, CASOperation, Transcoder)<T> boolean cas(String key, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException
T - key - operation - TimeoutExceptionInterruptedExceptionMemcachedExceptioncas(String, int, GetsResponse, CASOperation, Transcoder)<T> void casWithNoReply(String key, GetsResponse<T> getsResponse, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException
T - key - getsResponse - operation - TimeoutExceptionInterruptedExceptionMemcachedException<T> void casWithNoReply(String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException
T - key - exp - getsReponse - operation - TimeoutExceptionInterruptedExceptionMemcachedException<T> void casWithNoReply(String key, int exp, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException
T - key - exp - operation - TimeoutExceptionInterruptedExceptionMemcachedExceptioncasWithNoReply(String, int, GetsResponse, CASOperation)<T> void casWithNoReply(String key, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException
T - key - operation - TimeoutExceptionInterruptedExceptionMemcachedExceptioncasWithNoReply(String, int, GetsResponse, CASOperation)@Deprecated boolean delete(String key, int time) throws TimeoutException, InterruptedException, MemcachedException
key - time - InterruptedExceptionMemcachedExceptionTimeoutExceptionboolean delete(String key, long opTimeout) throws TimeoutException, InterruptedException, MemcachedException
key - opTimeout - Operation timeoutTimeoutExceptionInterruptedExceptionMemcachedExceptionboolean delete(String key, long cas, long opTimeout) throws TimeoutException, InterruptedException, MemcachedException
key - opTimeout - Operation timeoutTimeoutExceptionInterruptedExceptionMemcachedExceptionboolean touch(String key, int exp, long opTimeout) throws TimeoutException, InterruptedException, MemcachedException
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 timeoutTimeoutExceptionInterruptedExceptionMemcachedExceptionboolean touch(String key, int exp) throws TimeoutException, InterruptedException, MemcachedException
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.TimeoutExceptionInterruptedExceptionMemcachedException<T> T getAndTouch(String key, int newExp, long opTimeout) throws TimeoutException, InterruptedException, MemcachedException
T - 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 timeoutTimeoutExceptionInterruptedExceptionMemcachedException<T> T getAndTouch(String key, int newExp) throws TimeoutException, InterruptedException, MemcachedException
T - key - newExp - TimeoutExceptionInterruptedExceptionMemcachedExceptionMap<InetSocketAddress,String> getVersions() throws TimeoutException, InterruptedException, MemcachedException
long incr(String key, long delta) throws TimeoutException, InterruptedException, MemcachedException
key - num - InterruptedExceptionMemcachedExceptionTimeoutExceptionlong incr(String key, long delta, long initValue) throws TimeoutException, InterruptedException, MemcachedException
long incr(String key, long delta, long initValue, long timeout) throws TimeoutException, InterruptedException, MemcachedException
key - keynum - incrementinitValue - initValue if the data is not exists.timeout - operation timeoutTimeoutExceptionInterruptedExceptionMemcachedExceptionlong decr(String key, long delta) throws TimeoutException, InterruptedException, MemcachedException
key - num - InterruptedExceptionMemcachedExceptionTimeoutExceptionlong decr(String key, long delta, long initValue) throws TimeoutException, InterruptedException, MemcachedException
key - num - initValue - TimeoutExceptionInterruptedExceptionMemcachedExceptiondecrlong decr(String key, long delta, long initValue, long timeout) throws TimeoutException, InterruptedException, MemcachedException
key - The keynum - The incrementinitValue - The initial value if the data is not exists.timeout - Operation timeoutTimeoutExceptionInterruptedExceptionMemcachedExceptionvoid flushAll()
throws TimeoutException,
InterruptedException,
MemcachedException
void flushAllWithNoReply()
throws InterruptedException,
MemcachedException
void flushAll(long timeout)
throws TimeoutException,
InterruptedException,
MemcachedException
timeout - operation timeoutTimeoutExceptionInterruptedExceptionMemcachedExceptionvoid flushAll(InetSocketAddress address) throws MemcachedException, InterruptedException, TimeoutException
address - Target memcached servertimeout - operation timeoutTimeoutExceptionInterruptedExceptionMemcachedExceptionvoid flushAllWithNoReply(InetSocketAddress address) throws MemcachedException, InterruptedException
void flushAll(InetSocketAddress address, long timeout) throws MemcachedException, InterruptedException, TimeoutException
@Deprecated void flushAll(String host) throws TimeoutException, InterruptedException, MemcachedException
host - TimeoutExceptionInterruptedExceptionMemcachedExceptionMap<String,String> stats(InetSocketAddress address) throws MemcachedException, InterruptedException, TimeoutException
Map<String,String> stats(InetSocketAddress address, long timeout) throws MemcachedException, InterruptedException, TimeoutException
address - ����板�timeout - ���瓒��MemcachedExceptionInterruptedExceptionTimeoutExceptionMap<InetSocketAddress,Map<String,String>> getStats(long timeout) throws MemcachedException, InterruptedException, TimeoutException
timeout - MemcachedExceptionInterruptedExceptionTimeoutExceptionMap<InetSocketAddress,Map<String,String>> getStats() throws MemcachedException, InterruptedException, TimeoutException
Map<InetSocketAddress,Map<String,String>> getStatsByItem(String itemName) throws MemcachedException, InterruptedException, TimeoutException
item - MemcachedExceptionInterruptedExceptionTimeoutExceptionvoid shutdown()
throws IOException
IOExceptionboolean delete(String key) throws TimeoutException, InterruptedException, MemcachedException
Transcoder getTranscoder()
void setTranscoder(Transcoder transcoder)
transcoder - Map<InetSocketAddress,Map<String,String>> getStatsByItem(String itemName, long timeout) throws MemcachedException, InterruptedException, TimeoutException
long getOpTimeout()
void setOpTimeout(long opTimeout)
opTimeout - Map<InetSocketAddress,String> getVersions(long timeout) throws TimeoutException, InterruptedException, MemcachedException
@Deprecated Collection<InetSocketAddress> getAvaliableServers()
getAvailableServers()Collection<InetSocketAddress> getAvailableServers()
void addServer(String server, int port, int weight) throws IOException
server - port - weight - IOExceptionvoid addServer(InetSocketAddress inetSocketAddress, int weight) throws IOException
IOException@Deprecated void deleteWithNoReply(String key, int time) throws InterruptedException, MemcachedException
key - time - InterruptedExceptionMemcachedExceptionvoid deleteWithNoReply(String key) throws InterruptedException, MemcachedException
void incrWithNoReply(String key, long delta) throws InterruptedException, MemcachedException
key - num - InterruptedExceptionMemcachedExceptionvoid decrWithNoReply(String key, long delta) throws InterruptedException, MemcachedException
key - num - InterruptedExceptionMemcachedExceptionvoid setLoggingLevelVerbosity(InetSocketAddress address, int level) throws TimeoutException, InterruptedException, MemcachedException
address - level - logging levelTimeoutExceptionInterruptedExceptionMemcachedExceptionvoid setLoggingLevelVerbosityWithNoReply(InetSocketAddress address, int level) throws InterruptedException, MemcachedException
address - memcached server addresslevel - logging levelInterruptedExceptionMemcachedExceptionvoid addStateListener(MemcachedClientStateListener listener)
listener - void removeStateListener(MemcachedClientStateListener listener)
listener - Collection<MemcachedClientStateListener> getStateListeners()
void flushAllWithNoReply(int exptime)
throws InterruptedException,
MemcachedException
void flushAll(int exptime,
long timeout)
throws TimeoutException,
InterruptedException,
MemcachedException
void flushAllWithNoReply(InetSocketAddress address, int exptime) throws MemcachedException, InterruptedException
void flushAll(InetSocketAddress address, long timeout, int exptime) throws MemcachedException, InterruptedException, TimeoutException
void setHealSessionInterval(long healConnectionInterval)
healConnectionInterval - MILLISECONDSvoid setEnableHealSession(boolean enableHealSession)
client.setEnableHealSession(false); enableHealSession - long getHealSessionInterval()
Protocol getProtocol()
void setPrimitiveAsString(boolean primitiveAsString)
void setConnectionPoolSize(int poolSize)
poolSize - pool size,default is one,every memcached has only one
connection.void setEnableHeartBeat(boolean enableHeartBeat)
enableHeartBeat - if true,then enable heartbeat,true by defaultvoid setSanitizeKeys(boolean sanitizeKey)
sanitizeKey - if true, then URLEncode all keysboolean isSanitizeKeys()
Counter getCounter(String key)
key - Counter getCounter(String key, long initialValue)
key - initialValue - @Deprecated KeyIterator getKeyIterator(InetSocketAddress address) throws MemcachedException, InterruptedException, TimeoutException
address - MemcachedExceptionInterruptedExceptionTimeoutExceptionvoid setAuthInfoMap(Map<InetSocketAddress,AuthInfo> map)
map - Auth info map,key is memcached server address,and value is the
auth info for the key.Map<InetSocketAddress,AuthInfo> getAuthInfoMap()
long decr(String key, long delta, long initValue, long timeout, int exp) throws TimeoutException, InterruptedException, MemcachedException
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.TimeoutExceptionInterruptedExceptionMemcachedExceptionlong incr(String key, long delta, long initValue, long timeout, int exp) throws TimeoutException, InterruptedException, MemcachedException
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.TimeoutExceptionInterruptedExceptionMemcachedExceptionString getName()
void setName(String name)
name - Queue<ReconnectRequest> getReconnectRequestQueue()
void setFailureMode(boolean failureMode)
failureMode - true is to configure client in failure mode.boolean isFailureMode()
void setKeyProvider(KeyProvider keyProvider)
keyProvider - int getTimeoutExceptionThreshold()
void setTimeoutExceptionThreshold(int timeoutExceptionThreshold)
timeoutExceptionThreshold - DEFAULT_MAX_TIMEOUTEXCEPTION_THRESHOLDvoid invalidateNamespace(String ns) throws MemcachedException, InterruptedException, TimeoutException
ns - the namespaceMemcachedExceptionInterruptedExceptionTimeoutExceptionvoid invalidateNamespace(String ns, long opTimeout) throws MemcachedException, InterruptedException, TimeoutException
ns - the namespaceopTimeout - operation timeout in milliseconds.MemcachedExceptionInterruptedExceptionTimeoutExceptionvoid endWithNamespace()
beginWithNamespace(String) method.void beginWithNamespace(String ns)
endWithNamespace() method.For example:
memcachedClient.beginWithNamespace(userId);
try{
memcachedClient.set("username",0,username);
memcachedClient.set("email",0,email);
}finally{
memcachedClient.endWithNamespace();
}
<T> T withNamespace(String ns, MemcachedClientCallable<T> callable) throws MemcachedException, InterruptedException, TimeoutException
beginWithNamespace(String) and endWithNamespace() will called around automatically.
For example:
memcachedClient.withNamespace(userId,new MemcachedClientCallable{ public Void call(MemcachedClient client) throws MemcachedException, InterruptedException, TimeoutException{ client.set("username",0,username); client.set("email",0,email); return null; } }); //invalidate all items under the namespace. memcachedClient.invalidateNamespace(userId);
ns - callable - MemcachedExceptionInterruptedExceptionTimeoutExceptionbeginWithNamespace(String),
endWithNamespace()Copyright © 2013. All Rights Reserved.