public class XMemcachedClientBuilder extends Object implements MemcachedClientBuilder
Modifier and Type | Field and Description |
---|---|
protected Map<InetSocketAddress,InetSocketAddress> |
addressMap |
protected Map<InetSocketAddress,AuthInfo> |
authInfoMap |
protected BufferAllocator |
bufferAllocator |
protected CommandFactory |
commandFactory |
protected Configuration |
configuration |
protected int |
connectionPoolSize |
protected long |
connectTimeout |
protected boolean |
enableHealSession |
protected boolean |
failureMode |
protected long |
healSessionInterval |
protected KeyProvider |
keyProvider |
protected int |
maxQueuedNoReplyOperations |
protected String |
name |
protected long |
opTimeout |
protected boolean |
resolveInetAddresses |
protected boolean |
sanitizeKeys |
protected MemcachedSessionComparator |
sessionComparator |
protected MemcachedSessionLocator |
sessionLocator |
protected Map<SocketOption,Object> |
socketOptions |
protected List<MemcachedClientStateListener> |
stateListeners |
protected Transcoder |
transcoder |
protected int[] |
weights |
Constructor and Description |
---|
XMemcachedClientBuilder() |
XMemcachedClientBuilder(List<InetSocketAddress> addressList) |
XMemcachedClientBuilder(List<InetSocketAddress> addressList,
int[] weights) |
XMemcachedClientBuilder(Map<InetSocketAddress,InetSocketAddress> addressMap) |
XMemcachedClientBuilder(Map<InetSocketAddress,InetSocketAddress> addressMap,
int[] weights) |
XMemcachedClientBuilder(String addressList) |
Modifier and Type | Method and Description |
---|---|
void |
addAuthInfo(InetSocketAddress address,
AuthInfo authInfo)
Add auth info for memcached server
|
void |
addStateListener(MemcachedClientStateListener stateListener)
Add a state listener
|
MemcachedClient |
build()
Build MemcachedClient by current options.
|
protected void |
configureClient(XMemcachedClient memcachedClient) |
void |
doNotResolveInetAddresses() |
Map<InetSocketAddress,AuthInfo> |
getAuthInfoMap()
return current all auth info
|
BufferAllocator |
getBufferAllocator() |
CommandFactory |
getCommandFactory()
get xmemcached's command factory
|
Configuration |
getConfiguration()
Return the default networking's configuration,you can change them.
|
long |
getConnectTimeout()
Returns connect timeout in milliseconds
|
static Configuration |
getDefaultConfiguration() |
static Map<SocketOption,Object> |
getDefaultSocketOptions() |
long |
getHealSessionInterval() |
int |
getMaxQueuedNoReplyOperations() |
String |
getName()
Return the cache instance name
|
long |
getOpTimeout()
Returns the default operation timeout in milliseconds.
|
MemcachedSessionComparator |
getSessionComparator() |
MemcachedSessionLocator |
getSessionLocator() |
Map<SocketOption,Object> |
getSocketOptions()
Get all tcp socket options
|
Transcoder |
getTranscoder()
Set xmemcached's transcoder,it is used for seriailizing
|
boolean |
isEnableHealSession() |
boolean |
isFailureMode()
Returns if client is in failure mode.
|
boolean |
isResolveInetAddresses() |
void |
removeAuthInfo(InetSocketAddress address)
Remove auth info for memcached server
|
void |
removeStateListener(MemcachedClientStateListener stateListener)
Remove a state listener
|
void |
setAuthInfoMap(Map<InetSocketAddress,AuthInfo> authInfoMap)
Configure auth info
|
void |
setBufferAllocator(BufferAllocator bufferAllocator)
Set nio ByteBuffer's allocator.Use SimpleBufferAllocator by default.You can choose
CachedBufferAllocator.
|
void |
setCommandFactory(CommandFactory commandFactory)
set xmemcached's command factory.Default is TextCommandFactory,which implements memcached text
protocol.
|
void |
setConfiguration(Configuration configuration)
Set the XmemcachedClient's networking configuration(reuseAddr,receiveBufferSize,tcpDelay etc.)
|
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 connect timeout in milliseconds
|
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 |
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 healSessionInterval)
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 |
setMaxQueuedNoReplyOperations(int maxQueuedNoReplyOperations)
Set max queued noreply operations number
|
void |
setName(String name)
Set cache instance name
|
void |
setOpTimeout(long opTimeout)
Set default operation timeout.
|
void |
setResolveInetAddresses(boolean resolveInetAddresses) |
void |
setSanitizeKeys(boolean sanitizeKeys)
Enables/disables sanitizing keys by URLEncoding.
|
void |
setSelectorPoolSize(int selectorPoolSize) |
void |
setSessionComparator(MemcachedSessionComparator sessionComparator)
Set the XmemcachedClient's session comparator.Use IndexMemcachedSessionComparator by default.
|
void |
setSessionLocator(MemcachedSessionLocator sessionLocator)
Set the XmemcachedClient's session locator.Use ArrayMemcachedSessionLocator by default.If you
want to choose consistent hash strategy,set it to KetamaMemcachedSessionLocator
|
void |
setSocketOption(SocketOption socketOption,
Object value)
Set tcp socket option
|
void |
setStateListeners(List<MemcachedClientStateListener> stateListeners)
Set state listeners,replace current list
|
void |
setTranscoder(Transcoder transcoder) |
protected MemcachedSessionLocator sessionLocator
protected MemcachedSessionComparator sessionComparator
protected BufferAllocator bufferAllocator
protected Configuration configuration
protected Map<InetSocketAddress,InetSocketAddress> addressMap
protected int[] weights
protected long connectTimeout
protected int connectionPoolSize
protected final Map<SocketOption,Object> socketOptions
protected List<MemcachedClientStateListener> stateListeners
protected Map<InetSocketAddress,AuthInfo> authInfoMap
protected String name
protected boolean failureMode
protected boolean sanitizeKeys
protected KeyProvider keyProvider
protected int maxQueuedNoReplyOperations
protected long healSessionInterval
protected boolean enableHealSession
protected long opTimeout
protected boolean resolveInetAddresses
protected CommandFactory commandFactory
protected Transcoder transcoder
public XMemcachedClientBuilder(String addressList)
public XMemcachedClientBuilder(List<InetSocketAddress> addressList)
public XMemcachedClientBuilder(List<InetSocketAddress> addressList, int[] weights)
public XMemcachedClientBuilder(Map<InetSocketAddress,InetSocketAddress> addressMap)
public XMemcachedClientBuilder(Map<InetSocketAddress,InetSocketAddress> addressMap, int[] weights)
public XMemcachedClientBuilder()
public boolean isResolveInetAddresses()
public void setResolveInetAddresses(boolean resolveInetAddresses)
public void doNotResolveInetAddresses()
public long getOpTimeout()
MemcachedClientBuilder
getOpTimeout
in interface MemcachedClientBuilder
public void setOpTimeout(long opTimeout)
MemcachedClientBuilder
setOpTimeout
in interface MemcachedClientBuilder
opTimeout
- Operation timeout value in milliseconds.public int getMaxQueuedNoReplyOperations()
public long getHealSessionInterval()
public void setHealSessionInterval(long healSessionInterval)
MemcachedClientBuilder
setHealSessionInterval
in interface MemcachedClientBuilder
healSessionInterval
- MILLISECONDSpublic boolean isEnableHealSession()
public void setEnableHealSession(boolean enableHealSession)
MemcachedClientBuilder
client.setEnableHealSession(false);
setEnableHealSession
in interface MemcachedClientBuilder
public void setMaxQueuedNoReplyOperations(int maxQueuedNoReplyOperations)
setMaxQueuedNoReplyOperations
in interface MemcachedClientBuilder
maxQueuedNoReplyOperations
- MemcachedClient.DEFAULT_MAX_QUEUED_NOPS
public void setSanitizeKeys(boolean sanitizeKeys)
MemcachedClientBuilder
setSanitizeKeys
in interface MemcachedClientBuilder
public void addStateListener(MemcachedClientStateListener stateListener)
MemcachedClientBuilder
addStateListener
in interface MemcachedClientBuilder
public void setSocketOption(SocketOption socketOption, Object value)
MemcachedClientBuilder
setSocketOption
in interface MemcachedClientBuilder
public Map<SocketOption,Object> getSocketOptions()
MemcachedClientBuilder
getSocketOptions
in interface MemcachedClientBuilder
public final void setConnectionPoolSize(int poolSize)
MemcachedClientBuilder
setConnectionPoolSize
in interface MemcachedClientBuilder
poolSize
- pool size,default is 1public void removeStateListener(MemcachedClientStateListener stateListener)
MemcachedClientBuilder
removeStateListener
in interface MemcachedClientBuilder
public long getConnectTimeout()
MemcachedClientBuilder
getConnectTimeout
in interface MemcachedClientBuilder
public void setConnectTimeout(long connectTimeout)
MemcachedClientBuilder
setConnectTimeout
in interface MemcachedClientBuilder
MemcachedClient.DEFAULT_CONNECT_TIMEOUT
public void setStateListeners(List<MemcachedClientStateListener> stateListeners)
MemcachedClientBuilder
setStateListeners
in interface MemcachedClientBuilder
public static final Map<SocketOption,Object> getDefaultSocketOptions()
public static final Configuration getDefaultConfiguration()
public boolean isFailureMode()
MemcachedClientBuilder
isFailureMode
in interface MemcachedClientBuilder
public void setFailureMode(boolean failureMode)
MemcachedClientBuilder
setFailureMode
in interface MemcachedClientBuilder
failureMode
- true is to configure client in failure mode.public final CommandFactory getCommandFactory()
MemcachedClientBuilder
getCommandFactory
in interface MemcachedClientBuilder
public final void setCommandFactory(CommandFactory commandFactory)
MemcachedClientBuilder
setCommandFactory
in interface MemcachedClientBuilder
public MemcachedSessionLocator getSessionLocator()
getSessionLocator
in interface MemcachedClientBuilder
public void setSessionLocator(MemcachedSessionLocator sessionLocator)
MemcachedClientBuilder
setSessionLocator
in interface MemcachedClientBuilder
public MemcachedSessionComparator getSessionComparator()
getSessionComparator
in interface MemcachedClientBuilder
public void setSessionComparator(MemcachedSessionComparator sessionComparator)
MemcachedClientBuilder
setSessionComparator
in interface MemcachedClientBuilder
public BufferAllocator getBufferAllocator()
getBufferAllocator
in interface MemcachedClientBuilder
public void setBufferAllocator(BufferAllocator bufferAllocator)
MemcachedClientBuilder
setBufferAllocator
in interface MemcachedClientBuilder
public Configuration getConfiguration()
MemcachedClientBuilder
getConfiguration
in interface MemcachedClientBuilder
public void setConfiguration(Configuration configuration)
MemcachedClientBuilder
setConfiguration
in interface MemcachedClientBuilder
public MemcachedClient build() throws IOException
MemcachedClientBuilder
build
in interface MemcachedClientBuilder
IOException
protected void configureClient(XMemcachedClient memcachedClient)
public Transcoder getTranscoder()
MemcachedClientBuilder
getTranscoder
in interface MemcachedClientBuilder
public void setTranscoder(Transcoder transcoder)
setTranscoder
in interface MemcachedClientBuilder
public Map<InetSocketAddress,AuthInfo> getAuthInfoMap()
MemcachedClientBuilder
getAuthInfoMap
in interface MemcachedClientBuilder
public void setKeyProvider(KeyProvider keyProvider)
MemcachedClientBuilder
setKeyProvider
in interface MemcachedClientBuilder
public void addAuthInfo(InetSocketAddress address, AuthInfo authInfo)
MemcachedClientBuilder
addAuthInfo
in interface MemcachedClientBuilder
public void removeAuthInfo(InetSocketAddress address)
MemcachedClientBuilder
removeAuthInfo
in interface MemcachedClientBuilder
public void setAuthInfoMap(Map<InetSocketAddress,AuthInfo> authInfoMap)
MemcachedClientBuilder
setAuthInfoMap
in interface MemcachedClientBuilder
authInfoMap
- Auth info map,key is memcached server address,and value is the auth info for the
key.public String getName()
MemcachedClientBuilder
getName
in interface MemcachedClientBuilder
public void setName(String name)
MemcachedClientBuilder
setName
in interface MemcachedClientBuilder
public void setSelectorPoolSize(int selectorPoolSize)
Copyright © 2021. All rights reserved.