Interface MemcachedClientBuilder

All Known Implementing Classes:
AWSElasticCacheClientBuilder, XMemcachedClientBuilder

public interface MemcachedClientBuilder
Builder pattern.Configure XmemcachedClient's options,then build it
  • Method Details

    • 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 -
    • getSessionComparator

      MemcachedSessionComparator getSessionComparator()
      Returns:
      net.rubyeye.xmemcached.MemcachedSessionComparator
    • setSessionComparator

      void setSessionComparator(MemcachedSessionComparator sessionComparator)
      Set the XmemcachedClient's session comparator.Use IndexMemcachedSessionComparator by default.
      Parameters:
      sessionComparator -
    • 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

      Build MemcachedClient by current options.
      Returns:
      Throws:
      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 instead of 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(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, Object value)
      Set tcp socket option
      Parameters:
      socketOption -
      value -
    • getSocketOptions

      Map<SocketOption,Object> getSocketOptions()
      Get all tcp socket options
      Returns:
    • setAuthInfoMap

      void setAuthInfoMap(Map<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

      Map<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(InetSocketAddress address, AuthInfo authInfo)
      Add auth info for memcached server
      Parameters:
      address -
      authInfo -
    • removeAuthInfo

      void removeAuthInfo(InetSocketAddress address)
      Remove auth info for memcached server
      Parameters:
      address -
    • getName

      String getName()
      Return the cache instance name
      Returns:
    • setName

      void setName(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:
    • getConnectTimeout

      long getConnectTimeout()
      Returns connect timeout in milliseconds
      Returns:
      connect timeout
    • setConnectTimeout

      void setConnectTimeout(long connectTimeout)
      Set connect timeout in milliseconds
      Parameters:
      connectTimeout -
      See Also:
    • setSanitizeKeys

      void setSanitizeKeys(boolean sanitizeKeys)
      Enables/disables sanitizing keys by URLEncoding.
      Parameters:
      sanitizeKey - if true, then URLEncode all keys
    • setKeyProvider

      void setKeyProvider(KeyProvider keyProvider)
      Set a key provider for pre-processing keys before sending them to memcached.
      Parameters:
      keyProvider -
      Since:
      1.3.8
    • setMaxQueuedNoReplyOperations

      void setMaxQueuedNoReplyOperations(int maxQueuedNoReplyOperations)
      Set max queued noreply operations number
      Parameters:
      maxQueuedNoReplyOperations -
      Since:
      1.3.8
      See Also:
    • setHealSessionInterval

      void setHealSessionInterval(long healConnectionInterval)
      If the memcached dump or network error cause connection closed,xmemcached would try to heal the connection.The interval between reconnections is 2 seconds by default. You can change that value by this method.
      Parameters:
      healConnectionInterval - MILLISECONDS
      Since:
      1.3.9
    • setEnableHealSession

      void setEnableHealSession(boolean enableHealSession)
      If the memcached dump or network error cause connection closed,xmemcached would try to heal the connection.You can disable this behaviour by using this method:
      client.setEnableHealSession(false);
      The default value is true.
      Parameters:
      enableHealSession -
      Since:
      1.3.9
    • setOpTimeout

      void setOpTimeout(long opTimeout)
      Set default operation timeout.
      Parameters:
      opTimeout - Operation timeout value in milliseconds.
      Since:
      1.4.1
    • getOpTimeout

      long getOpTimeout()
      Returns the default operation timeout in milliseconds.
      Returns:
      Since:
      1.4.1