public interface MemcachedClient
Modifier and Type | Field and Description |
---|---|
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 |
Modifier and Type | Method and Description |
---|---|
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: |
<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)
Deprecated.
|
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)
Deprecated.
|
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)
Deprecated.
|
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
|
Map<String,AuthInfo> |
getAuthInfoStringMap()
Retruns the AuthInfo for all server strings (hostname:port)
|
Collection<InetSocketAddress> |
getAvailableServers()
Returns available memcached servers list.
|
Collection<InetSocketAddress> |
getAvaliableServers()
Deprecated.
|
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)
Deprecated.
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(InetSocketAddress address)
Remove memcached server with the exact given address.
|
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)
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 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 numberIOException
void addServer(InetSocketAddress inetSocketAddress) throws IOException
inetSocketAddress
- memcached server's socket addressIOException
void addServer(String hostList) throws IOException
host
- String like [host1]:[port1] [host2]:[port2] ...IOException
List<String> getServersDescription()
void removeServer(String hostList)
host
- String like [host1]:[port1] [host2]:[port2] ...void removeServer(InetSocketAddress address)
address
- Resolved server address@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 transcoderTimeoutException
InterruptedException
MemcachedException
<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
- TimeoutException
InterruptedException
MemcachedException
<T> GetsResponse<T> gets(String key) throws TimeoutException, InterruptedException, MemcachedException
T
- key
- TimeoutException
InterruptedException
MemcachedException
gets(String, long, Transcoder)
<T> GetsResponse<T> gets(String key, long timeout) throws TimeoutException, InterruptedException, MemcachedException
T
- key
- timeout
- TimeoutException
InterruptedException
MemcachedException
gets(String, long, Transcoder)
<T> GetsResponse<T> gets(String key, Transcoder transcoder) throws TimeoutException, InterruptedException, MemcachedException
T
- key
- transcoder
- TimeoutException
InterruptedException
MemcachedException
gets(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 transcoderTimeoutException
InterruptedException
MemcachedException
<T> Map<String,T> get(Collection<String> keyCollections, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException
T
- keyCollections
- transcoder
- TimeoutException
InterruptedException
MemcachedException
get(Collection, long, Transcoder)
<T> Map<String,T> get(Collection<String> keyCollections) throws TimeoutException, InterruptedException, MemcachedException
T
- keyCollections
- TimeoutException
InterruptedException
MemcachedException
get(Collection, long, Transcoder)
<T> Map<String,T> get(Collection<String> keyCollections, long timeout) throws TimeoutException, InterruptedException, MemcachedException
T
- keyCollections
- timeout
- TimeoutException
InterruptedException
MemcachedException
get(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 transcoderTimeoutException
InterruptedException
MemcachedException
GetsResponse
<T> Map<String,GetsResponse<T>> gets(Collection<String> keyCollections) throws TimeoutException, InterruptedException, MemcachedException
T
- keyCollections
- TimeoutException
InterruptedException
MemcachedException
gets(Collection, long, Transcoder)
<T> Map<String,GetsResponse<T>> gets(Collection<String> keyCollections, long timeout) throws TimeoutException, InterruptedException, MemcachedException
T
- keyCollections
- timeout
- TimeoutException
InterruptedException
MemcachedException
gets(Collection, long, Transcoder)
<T> Map<String,GetsResponse<T>> gets(Collection<String> keyCollections, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException
T
- keyCollections
- transcoder
- TimeoutException
InterruptedException
MemcachedException
gets(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 millisecondsTimeoutException
InterruptedException
MemcachedException
boolean 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
- transocderTimeoutException
InterruptedException
MemcachedException
<T> void setWithNoReply(String key, int exp, T value, Transcoder<T> transcoder) throws InterruptedException, MemcachedException
T
- key
- exp
- value
- transcoder
- InterruptedException
MemcachedException
setWithNoReply(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
- TimeoutException
InterruptedException
MemcachedException
boolean add(String key, int exp, Object value) throws TimeoutException, InterruptedException, MemcachedException
key
- exp
- value
- TimeoutException
InterruptedException
MemcachedException
add(String, int, Object, Transcoder, long)
boolean add(String key, int exp, Object value, long timeout) throws TimeoutException, InterruptedException, MemcachedException
key
- exp
- value
- timeout
- TimeoutException
InterruptedException
MemcachedException
add(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
- TimeoutException
InterruptedException
MemcachedException
add(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
- TimeoutException
InterruptedException
MemcachedException
<T> void addWithNoReply(String key, int exp, T value, Transcoder<T> transcoder) throws InterruptedException, MemcachedException
T
- key
- exp
- value
- transcoder
- InterruptedException
MemcachedException
addWithNoReply(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
- TimeoutException
InterruptedException
MemcachedException
boolean replace(String key, int exp, Object value) throws TimeoutException, InterruptedException, MemcachedException
key
- exp
- value
- TimeoutException
InterruptedException
MemcachedException
replace(String, int, Object, Transcoder, long)
boolean replace(String key, int exp, Object value, long timeout) throws TimeoutException, InterruptedException, MemcachedException
key
- exp
- value
- timeout
- TimeoutException
InterruptedException
MemcachedException
replace(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
- TimeoutException
InterruptedException
MemcachedException
replace(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
- TimeoutException
InterruptedException
MemcachedException
<T> void replaceWithNoReply(String key, int exp, T value, Transcoder<T> transcoder) throws InterruptedException, MemcachedException
T
- key
- exp
- value
- transcoder
- InterruptedException
MemcachedException
replaceWithNoReply(String, int, Object, Transcoder)
boolean append(String key, Object value) throws TimeoutException, InterruptedException, MemcachedException
key
- value
- TimeoutException
InterruptedException
MemcachedException
append(String, Object, long)
boolean append(String key, Object value, long timeout) throws TimeoutException, InterruptedException, MemcachedException
key
- value
- timeout
- TimeoutException
InterruptedException
MemcachedException
void appendWithNoReply(String key, Object value) throws InterruptedException, MemcachedException
key
- value
- TimeoutException
InterruptedException
MemcachedException
boolean prepend(String key, Object value) throws TimeoutException, InterruptedException, MemcachedException
key
- value
- TimeoutException
InterruptedException
MemcachedException
prepend(String, Object, long)
boolean prepend(String key, Object value, long timeout) throws TimeoutException, InterruptedException, MemcachedException
key
- value
- TimeoutException
InterruptedException
MemcachedException
void prependWithNoReply(String key, Object value) throws InterruptedException, MemcachedException
key
- value
- TimeoutException
InterruptedException
MemcachedException
boolean cas(String key, int exp, Object value, long cas) throws TimeoutException, InterruptedException, MemcachedException
key
- exp
- value
- cas
- TimeoutException
InterruptedException
MemcachedException
cas(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
- TimeoutException
InterruptedException
MemcachedException
boolean cas(String key, int exp, Object value, long timeout, long cas) throws TimeoutException, InterruptedException, MemcachedException
key
- exp
- value
- timeout
- cas
- TimeoutException
InterruptedException
MemcachedException
cas(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
- TimeoutException
InterruptedException
MemcachedException
cas(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 transcoderTimeoutException
InterruptedException
MemcachedException
<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
- TimeoutException
InterruptedException
MemcachedException
<T> boolean cas(String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException
T
- key
- exp
- getsReponse
- operation
- TimeoutException
InterruptedException
MemcachedException
cas(String, int, GetsResponse, CASOperation, Transcoder)
<T> boolean cas(String key, GetsResponse<T> getsResponse, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException
T
- key
- getsResponse
- operation
- TimeoutException
InterruptedException
MemcachedException
cas(String, int, GetsResponse, CASOperation, Transcoder)
<T> boolean cas(String key, int exp, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException
T
- key
- exp
- operation
- TimeoutException
InterruptedException
MemcachedException
cas(String, int, GetsResponse, CASOperation, Transcoder)
<T> boolean cas(String key, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException
T
- key
- operation
- TimeoutException
InterruptedException
MemcachedException
cas(String, int, GetsResponse, CASOperation, Transcoder)
<T> void casWithNoReply(String key, GetsResponse<T> getsResponse, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException
T
- key
- getsResponse
- operation
- TimeoutException
InterruptedException
MemcachedException
<T> void casWithNoReply(String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException
T
- key
- exp
- getsReponse
- operation
- TimeoutException
InterruptedException
MemcachedException
<T> void casWithNoReply(String key, int exp, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException
T
- key
- exp
- operation
- TimeoutException
InterruptedException
MemcachedException
casWithNoReply(String, int, GetsResponse, CASOperation)
<T> void casWithNoReply(String key, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException
T
- key
- operation
- TimeoutException
InterruptedException
MemcachedException
casWithNoReply(String, int, GetsResponse, CASOperation)
@Deprecated boolean delete(String key, int time) throws TimeoutException, InterruptedException, MemcachedException
key
- time
- InterruptedException
MemcachedException
TimeoutException
boolean delete(String key, long opTimeout) throws TimeoutException, InterruptedException, MemcachedException
key
- opTimeout
- Operation timeoutTimeoutException
InterruptedException
MemcachedException
boolean delete(String key, long cas, long opTimeout) throws TimeoutException, InterruptedException, MemcachedException
key
- opTimeout
- Operation timeoutTimeoutException
InterruptedException
MemcachedException
boolean 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 timeoutTimeoutException
InterruptedException
MemcachedException
boolean 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.TimeoutException
InterruptedException
MemcachedException
<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 timeoutTimeoutException
InterruptedException
MemcachedException
<T> T getAndTouch(String key, int newExp) throws TimeoutException, InterruptedException, MemcachedException
T
- key
- newExp
- TimeoutException
InterruptedException
MemcachedException
Map<InetSocketAddress,String> getVersions() throws TimeoutException, InterruptedException, MemcachedException
TimeoutException
InterruptedException
MemcachedException
long incr(String key, long delta) throws TimeoutException, InterruptedException, MemcachedException
key
- num
- InterruptedException
MemcachedException
TimeoutException
long 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 timeoutTimeoutException
InterruptedException
MemcachedException
long decr(String key, long delta) throws TimeoutException, InterruptedException, MemcachedException
key
- num
- InterruptedException
MemcachedException
TimeoutException
long decr(String key, long delta, long initValue) throws TimeoutException, InterruptedException, MemcachedException
key
- num
- initValue
- TimeoutException
InterruptedException
MemcachedException
decr
long 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 timeoutTimeoutException
InterruptedException
MemcachedException
void flushAll() throws TimeoutException, InterruptedException, MemcachedException
void flushAllWithNoReply() throws InterruptedException, MemcachedException
void flushAll(long timeout) throws TimeoutException, InterruptedException, MemcachedException
timeout
- operation timeoutTimeoutException
InterruptedException
MemcachedException
void flushAll(InetSocketAddress address) throws MemcachedException, InterruptedException, TimeoutException
address
- Target memcached servertimeout
- operation timeoutTimeoutException
InterruptedException
MemcachedException
void 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
- TimeoutException
InterruptedException
MemcachedException
Map<String,String> stats(InetSocketAddress address) throws MemcachedException, InterruptedException, TimeoutException
Map<String,String> stats(InetSocketAddress address, long timeout) throws MemcachedException, InterruptedException, TimeoutException
address
- ����板�timeout
- ���瓒��MemcachedException
InterruptedException
TimeoutException
Map<InetSocketAddress,Map<String,String>> getStats(long timeout) throws MemcachedException, InterruptedException, TimeoutException
timeout
- MemcachedException
InterruptedException
TimeoutException
Map<InetSocketAddress,Map<String,String>> getStats() throws MemcachedException, InterruptedException, TimeoutException
Map<InetSocketAddress,Map<String,String>> getStatsByItem(String itemName) throws MemcachedException, InterruptedException, TimeoutException
item
- MemcachedException
InterruptedException
TimeoutException
void shutdown() throws IOException
IOException
boolean 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
- IOException
void addServer(InetSocketAddress inetSocketAddress, int weight) throws IOException
IOException
@Deprecated void deleteWithNoReply(String key, int time) throws InterruptedException, MemcachedException
key
- time
- InterruptedException
MemcachedException
void deleteWithNoReply(String key) throws InterruptedException, MemcachedException
void incrWithNoReply(String key, long delta) throws InterruptedException, MemcachedException
key
- num
- InterruptedException
MemcachedException
void decrWithNoReply(String key, long delta) throws InterruptedException, MemcachedException
key
- num
- InterruptedException
MemcachedException
void setLoggingLevelVerbosity(InetSocketAddress address, int level) throws TimeoutException, InterruptedException, MemcachedException
address
- level
- logging levelTimeoutException
InterruptedException
MemcachedException
void setLoggingLevelVerbosityWithNoReply(InetSocketAddress address, int level) throws InterruptedException, MemcachedException
address
- memcached server addresslevel
- logging levelInterruptedException
MemcachedException
void 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
- MemcachedException
InterruptedException
TimeoutException
void 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()
Map<String,AuthInfo> getAuthInfoStringMap()
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.TimeoutException
InterruptedException
MemcachedException
long 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.TimeoutException
InterruptedException
MemcachedException
String 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_THRESHOLD
void invalidateNamespace(String ns) throws MemcachedException, InterruptedException, TimeoutException
ns
- the namespaceMemcachedException
InterruptedException
TimeoutException
void invalidateNamespace(String ns, long opTimeout) throws MemcachedException, InterruptedException, TimeoutException
ns
- the namespaceopTimeout
- operation timeout in milliseconds.MemcachedException
InterruptedException
TimeoutException
void endWithNamespace()
beginWithNamespace(String)
method.beginWithNamespace(String)
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(); }
ns
- endWithNamespace()
,
withNamespace(String, MemcachedClientCallable)
<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
- MemcachedException
InterruptedException
TimeoutException
beginWithNamespace(String)
,
endWithNamespace()
Copyright © 2021. All rights reserved.