net.rubyeye.xmemcached
Interface MemcachedClientBuilder

All Known Implementing Classes:
XMemcachedClientBuilder

public interface MemcachedClientBuilder

Builder pattern.Configure XmemcachedClient's options,then build it

Author:
dennis

Method Summary
 void addAuthInfo(java.net.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.
 java.util.Map<java.net.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.
 java.lang.String getName()
          Return the cache instance name
 MemcachedSessionLocator getSessionLocator()
           
 java.util.Map<SocketOption,java.lang.Object> getSocketOptions()
          Get all tcp socket options
 Transcoder getTranscoder()
          Set xmemcached's transcoder,it is used for seriailizing
 boolean isFailureMode()
          Returns if client is in failure mode.
 void removeAuthInfo(java.net.InetSocketAddress address)
          Remove auth info for memcached server
 void removeStateListener(MemcachedClientStateListener stateListener)
          Remove a state listener
 void setAuthInfoMap(java.util.Map<java.net.InetSocketAddress,AuthInfo> map)
          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 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 setName(java.lang.String name)
          Set cache instance name
 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, java.lang.Object value)
          Set tcp socket option
 void setStateListeners(java.util.List<MemcachedClientStateListener> stateListeners)
          Set state listeners,replace current list
 void setTranscoder(Transcoder transcoder)
           
 

Method Detail

getSessionLocator

MemcachedSessionLocator getSessionLocator()
Returns:
net.rubyeye.xmemcached.MemcachedSessionLocator

setSessionLocator

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

Parameters:
sessionLocator -

getBufferAllocator

BufferAllocator getBufferAllocator()

setBufferAllocator

void setBufferAllocator(BufferAllocator bufferAllocator)
Set nio ByteBuffer's allocator.Use SimpleBufferAllocator by default.You can choose CachedBufferAllocator.

Parameters:
bufferAllocator -

getConfiguration

Configuration getConfiguration()
Return the default networking's configuration,you can change them.

Returns:

setConfiguration

void setConfiguration(Configuration configuration)
Set the XmemcachedClient's networking configuration(reuseAddr,receiveBufferSize,tcpDelay etc.)

Parameters:
configuration -

build

MemcachedClient build()
                      throws java.io.IOException
Build MemcachedClient by current options.

Returns:
Throws:
java.io.IOException

setConnectionPoolSize

void setConnectionPoolSize(int poolSize)
In a high concurrent enviroment,you may want to pool memcached clients.But a xmemcached client has to start a reactor thread and some thread pools,if you create too many clients,the cost is very large. Xmemcached supports connection pool instreadof client pool.you can create more connections to one or more memcached servers,and these connections share the same reactor and thread pools,it will reduce the cost of system.

Parameters:
poolSize - pool size,default is 1

getTranscoder

Transcoder getTranscoder()
Set xmemcached's transcoder,it is used for seriailizing

Returns:

setTranscoder

void setTranscoder(Transcoder transcoder)

getCommandFactory

CommandFactory getCommandFactory()
get xmemcached's command factory

Returns:

addStateListener

void addStateListener(MemcachedClientStateListener stateListener)
Add a state listener

Parameters:
stateListener -

removeStateListener

void removeStateListener(MemcachedClientStateListener stateListener)
Remove a state listener

Parameters:
stateListener -

setStateListeners

void setStateListeners(java.util.List<MemcachedClientStateListener> stateListeners)
Set state listeners,replace current list

Parameters:
stateListeners -

setCommandFactory

void setCommandFactory(CommandFactory commandFactory)
set xmemcached's command factory.Default is TextCommandFactory,which implements memcached text protocol.

Parameters:
commandFactory -

setSocketOption

void setSocketOption(SocketOption socketOption,
                     java.lang.Object value)
Set tcp socket option

Parameters:
socketOption -
value -

getSocketOptions

java.util.Map<SocketOption,java.lang.Object> getSocketOptions()
Get all tcp socket options

Returns:

setAuthInfoMap

void setAuthInfoMap(java.util.Map<java.net.InetSocketAddress,AuthInfo> map)
Configure auth info

Parameters:
map - Auth info map,key is memcached server address,and value is the auth info for the key.

getAuthInfoMap

java.util.Map<java.net.InetSocketAddress,AuthInfo> getAuthInfoMap()
return current all auth info

Returns:
Auth info map,key is memcached server address,and value is the auth info for the key.

addAuthInfo

void addAuthInfo(java.net.InetSocketAddress address,
                 AuthInfo authInfo)
Add auth info for memcached server

Parameters:
address -
authInfo -

removeAuthInfo

void removeAuthInfo(java.net.InetSocketAddress address)
Remove auth info for memcached server

Parameters:
address -

getName

java.lang.String getName()
Return the cache instance name

Returns:

setName

void setName(java.lang.String name)
Set cache instance name

Parameters:
name -

setFailureMode

void setFailureMode(boolean failureMode)
Configure wheather to set client in failure mode.If set it to true,that means you want to configure client in failure mode. Failure mode is that when a memcached server is down,it would not taken from the server list but marked as unavailable,and then further requests to this server will be transformed to standby node if configured or throw an exception until it comes back up.

Parameters:
failureMode - true is to configure client in failure mode.

isFailureMode

boolean isFailureMode()
Returns if client is in failure mode.

Returns:


Copyright © 2011. All Rights Reserved.