Class XMemcachedClient

    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      boolean add​(java.lang.String key, int exp, java.lang.Object value)  
      boolean add​(java.lang.String key, int exp, java.lang.Object value, long timeout)  
      <T> boolean add​(java.lang.String key, int exp, T value, Transcoder<T> transcoder)  
      <T> boolean add​(java.lang.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.
      private <T> boolean add0​(java.lang.String key, int exp, T value, Transcoder<T> transcoder, long timeout)  
      void addOneServerWithWeight​(java.lang.String server, int weight)
      Add a memcached server
      void addServer​(java.lang.String hostList)
      Add memcached servers
      void addServer​(java.lang.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​(java.lang.String server, int port, int weight)
      add a memcached server to MemcachedClient
      void addServer​(java.net.InetSocketAddress inetSocketAddress)
      Add a memcached server,the thread call this method will be blocked until the connecting operations completed(success or fail)
      void addServer​(java.net.InetSocketAddress inetSocketAddress, int weight)  
      void addStateListener​(MemcachedClientStateListener listener)
      Add a memcached client listener
      void addWithNoReply​(java.lang.String key, int exp, java.lang.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​(java.lang.String key, int exp, T value, Transcoder<T> transcoder)  
      boolean append​(java.lang.String key, java.lang.Object value)  
      boolean append​(java.lang.String key, java.lang.Object value, long timeout)
      Append value to key's data item,this method will wait for reply
      void appendWithNoReply​(java.lang.String key, java.lang.Object value)
      Append value to key's data item,this method doesn't wait for reply.
      void beginWithNamespace​(java.lang.String ns)
      set current namespace for following operations with memcached client.It must be ended with MemcachedClient.endWithNamespace() method.For example:
      private void buildConnector​(MemcachedSessionLocator locator, MemcachedSessionComparator comparator, BufferAllocator bufferAllocator, Configuration configuration, java.util.Map<SocketOption,​java.lang.Object> socketOptions, CommandFactory commandFactory, Transcoder transcoder)  
      boolean cas​(java.lang.String key, int exp, java.lang.Object value, long cas)  
      boolean cas​(java.lang.String key, int exp, java.lang.Object value, long timeout, long cas)  
      <T> boolean cas​(java.lang.String key, int exp, CASOperation<T> operation)  
      <T> boolean cas​(java.lang.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​(java.lang.String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation)  
      <T> boolean cas​(java.lang.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."
      <T> boolean cas​(java.lang.String key, int exp, T value, Transcoder<T> transcoder, long cas)  
      <T> boolean cas​(java.lang.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> boolean cas​(java.lang.String key, CASOperation<T> operation)  
      <T> boolean cas​(java.lang.String key, GetsResponse<T> getsReponse, CASOperation<T> operation)  
      private <T> boolean cas0​(java.lang.String key, int exp, GetsResponse<T> getsResponse, CASOperation<T> operation, Transcoder<T> transcoder, byte[] keyBytes, boolean noreply)  
      <T> void casWithNoReply​(java.lang.String key, int exp, CASOperation<T> operation)  
      <T> void casWithNoReply​(java.lang.String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation)
      cas noreply
      <T> void casWithNoReply​(java.lang.String key, CASOperation<T> operation)  
      <T> void casWithNoReply​(java.lang.String key, GetsResponse<T> getsResponse, CASOperation<T> operation)  
      private java.util.Collection<java.util.List<java.lang.String>> catalogKeys​(java.util.Collection<java.lang.String> keyCollections)
      Hash key to servers
      protected void checkException​(Command command)  
      private void checkServerPort​(java.lang.String server, int port)  
      private <T> byte[] checkStoreArguments​(java.lang.String key, int exp, T value)  
      protected void connect​(InetSocketAddressWrapper inetSocketAddressWrapper)  
      private java.lang.String decodeKey​(java.lang.String key)  
      long decr​(java.lang.String key, long delta)
      "decr" are used to change data for some item in-place, decrementing it.
      long decr​(java.lang.String key, long delta, long initValue)  
      long decr​(java.lang.String key, long delta, long initValue, long timeout)
      "decr" are used to change data for some item in-place, decrementing it.
      long decr​(java.lang.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​(java.lang.String key, long delta)
      "decr" are used to change data for some item in-place, decrementing it.
      boolean delete​(java.lang.String key)  
      boolean delete​(java.lang.String key, int time)
      Delete key's data item from memcached.It it is not exists,return false.
      time is the amount of time in seconds (or Unix time until
      which) the client wishes the server to refuse "add" and "replace"
      commands with this key.
      boolean delete​(java.lang.String key, long opTimeout)
      Delete key's date item from memcached
      boolean delete​(java.lang.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.
      private boolean delete0​(java.lang.String key, int time, long cas, boolean noreply, long opTimeout)  
      void deleteWithNoReply​(java.lang.String key)  
      void deleteWithNoReply​(java.lang.String key, int time)
      Delete key's data item from memcached.This method doesn't wait for reply
      void endWithNamespace()
      Remove current namespace set for this memcached client.It must begin with MemcachedClient.beginWithNamespace(String) method.
      private <T> java.lang.Object fetch0​(java.lang.String key, byte[] keyBytes, CommandType cmdType, long timeout, Transcoder<T> transcoder)  
      void flushAll()
      Make All connected memcached's data item invalid
      void flushAll​(int exptime, long timeout)  
      void flushAll​(long timeout)
      Make All connected memcached's data item invalid
      void flushAll​(java.lang.String host)
      This method is deprecated,please use flushAll(InetSocketAddress) instead.
      void flushAll​(java.net.InetSocketAddress address)
      Invalidate all existing items immediately
      void flushAll​(java.net.InetSocketAddress address, long timeout)  
      void flushAll​(java.net.InetSocketAddress address, long timeout, int exptime)  
      private void flushAllMemcachedServers​(long timeout, boolean noreply, int exptime)  
      void flushAllWithNoReply()  
      void flushAllWithNoReply​(int exptime)  
      void flushAllWithNoReply​(java.net.InetSocketAddress address)  
      void flushAllWithNoReply​(java.net.InetSocketAddress address, int exptime)  
      private void flushSpecialMemcachedServer​(java.net.InetSocketAddress address, long timeout, boolean noreply, int exptime)  
      <T> T get​(java.lang.String key)  
      <T> T get​(java.lang.String key, long timeout)  
      <T> T get​(java.lang.String key, long timeout, Transcoder<T> transcoder)
      Get value by key
      <T> T get​(java.lang.String key, Transcoder<T> transcoder)  
      <T> java.util.Map<java.lang.String,​T> get​(java.util.Collection<java.lang.String> keyCollections)  
      <T> java.util.Map<java.lang.String,​T> get​(java.util.Collection<java.lang.String> keyCollections, long timeout)  
      <T> java.util.Map<java.lang.String,​T> get​(java.util.Collection<java.lang.String> keyCollections, long timeout, Transcoder<T> transcoder)
      Bulk get items
      <T> java.util.Map<java.lang.String,​T> get​(java.util.Collection<java.lang.String> keyCollections, Transcoder<T> transcoder)  
      private <T> java.lang.Object get0​(java.lang.String key, long timeout, CommandType cmdType, Transcoder<T> transcoder)  
      <T> T getAndTouch​(java.lang.String key, int newExp)
      Get item and set a new expiration time for it,using default opTimeout
      <T> T getAndTouch​(java.lang.String key, int newExp, long opTimeout)
      Get item and set a new expiration time for it
      java.util.Map<java.net.InetSocketAddress,​AuthInfo> getAuthInfoMap()
      return current all auth info
      java.util.Map<java.lang.String,​AuthInfo> getAuthInfoStringMap()
      Retruns the AuthInfo for all server strings (hostname:port)
      java.util.Collection<java.net.InetSocketAddress> getAvailableServers()
      Returns available memcached servers list.
      java.util.Collection<java.net.InetSocketAddress> getAvaliableServers()
      Deprecated. 
      CommandFactory getCommandFactory()  
      int getConnectionSizeBySocketAddress​(java.net.InetSocketAddress address)  
      Connector getConnector()
      return the session manager
      long getConnectTimeout()
      Get the connect timeout
      private java.util.concurrent.atomic.AtomicInteger getContinuousTimeoutCounter​(Session session)  
      Counter getCounter​(java.lang.String key)
      Get counter for key,and if the key's value is not set,then set it with 0.
      Counter getCounter​(java.lang.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​(java.net.InetSocketAddress address)
      Deprecated.
      memcached 1.6.x will remove cachedump stats command,so this method will be removed in the future
      KeyProvider getKeyProvider()  
      private <T> java.util.Map<java.lang.String,​T> getMulti0​(java.util.Collection<java.lang.String> keys, long timeout, CommandType cmdType, Transcoder<T> transcoder)  
      java.lang.String getName()
      Return the cache instance name
      java.lang.String getNamespace​(java.lang.String ns)
      Returns the real namespace of ns.
      private java.lang.String getNSKey​(java.lang.String ns)  
      long getOpTimeout()
      get operation timeout setting
      Protocol getProtocol()  
      java.util.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> GetsResponse<T> gets​(java.lang.String key)  
      <T> GetsResponse<T> gets​(java.lang.String key, long timeout)  
      <T> GetsResponse<T> gets​(java.lang.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​(java.lang.String key, Transcoder transcoder)  
      <T> java.util.Map<java.lang.String,​GetsResponse<T>> gets​(java.util.Collection<java.lang.String> keyCollections)  
      <T> java.util.Map<java.lang.String,​GetsResponse<T>> gets​(java.util.Collection<java.lang.String> keyCollections, long timeout)  
      <T> java.util.Map<java.lang.String,​GetsResponse<T>> gets​(java.util.Collection<java.lang.String> keyCollections, long timeout, Transcoder<T> transcoder)
      Bulk gets items
      <T> java.util.Map<java.lang.String,​GetsResponse<T>> gets​(java.util.Collection<java.lang.String> keyCollections, Transcoder<T> transcoder)  
      private <T> GetsResponse<T> gets0​(java.lang.String key, byte[] keyBytes, Transcoder<T> transcoder)  
      java.util.List<java.lang.String> getServersDescription()
      Get all connected memcached servers
      MemcachedSessionComparator getSessionComparator()  
      MemcachedSessionLocator getSessionLocator()  
      java.util.Collection<MemcachedClientStateListener> getStateListeners()
      Get all current state listeners
      java.util.Map<java.net.InetSocketAddress,​java.util.Map<java.lang.String,​java.lang.String>> getStats()  
      java.util.Map<java.net.InetSocketAddress,​java.util.Map<java.lang.String,​java.lang.String>> getStats​(long timeout)
      Get stats from all memcached servers
      java.util.Map<java.net.InetSocketAddress,​java.util.Map<java.lang.String,​java.lang.String>> getStatsByItem​(java.lang.String itemName)
      Get special item stats.
      java.util.Map<java.net.InetSocketAddress,​java.util.Map<java.lang.String,​java.lang.String>> getStatsByItem​(java.lang.String itemName, long timeout)  
      int getTimeoutExceptionThreshold()
      Returns maximum number of timeout exception for closing connection.
      Transcoder getTranscoder()
      return default transcoder,default is SerializingTranscoder
      java.util.Map<java.net.InetSocketAddress,​java.lang.String> getVersions()
      Get all connected memcached servers's version.
      java.util.Map<java.net.InetSocketAddress,​java.lang.String> getVersions​(long timeout)  
      long incr​(java.lang.String key, long delta)
      "incr" are used to change data for some item in-place, incrementing it.
      long incr​(java.lang.String key, long delta, long initValue)  
      long incr​(java.lang.String key, long delta, long initValue, long timeout)
      "incr" are used to change data for some item in-place, incrementing it.
      long incr​(java.lang.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​(java.lang.String key, long delta)
      "incr" are used to change data for some item in-place, incrementing it.
      void invalidateNamespace​(java.lang.String ns)
      Invalidate all namespace under the namespace using the default operation timeout.
      void invalidateNamespace​(java.lang.String ns, long opTimeout)
      Invalidate all items under the namespace.
      boolean isFailureMode()
      Returns if client is in failure mode.
      boolean isSanitizeKeys()  
      boolean isShutdown()  
      private boolean isWindowsPlatform()  
      protected void latchWait​(Command cmd, long timeout, Session session)  
      protected MemcachedConnector newConnector​(BufferAllocator bufferAllocator, Configuration configuration, MemcachedSessionLocator memcachedSessionLocator, MemcachedSessionComparator memcachedSessionComparator, CommandFactory commandFactory, int poolSize, int maxQueuedNoReplyOperations)  
      protected java.net.InetSocketAddress newSocketAddress​(java.lang.String server, int port)  
      private void optimiezeSetReadThreadCount​(Configuration conf, int addressCount)  
      boolean prepend​(java.lang.String key, java.lang.Object value)  
      boolean prepend​(java.lang.String key, java.lang.Object value, long timeout)
      Prepend value to key's data item in memcached.This method doesn't wait for reply.
      void prependWithNoReply​(java.lang.String key, java.lang.Object value)
      Prepend value to key's data item in memcached.This method doesn't wait for reply.
      private java.lang.String preProcessKey​(java.lang.String key)  
      private <T> java.util.Map<java.lang.String,​T> reduceResult​(CommandType cmdType, Transcoder<T> transcoder, java.util.List<Command> commands)  
      private void registerMBean()  
      void removeServer​(java.lang.String hostList)
      Remove memcached servers
      void removeServer​(java.net.InetSocketAddress address)
      Remove memcached server with the exact given address.
      void removeStateListener​(MemcachedClientStateListener listener)
      Remove a memcached client listener
      boolean replace​(java.lang.String key, int exp, java.lang.Object value)  
      boolean replace​(java.lang.String key, int exp, java.lang.Object value, long timeout)  
      <T> boolean replace​(java.lang.String key, int exp, T value, Transcoder<T> transcoder)  
      <T> boolean replace​(java.lang.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​(java.lang.String key, int exp, java.lang.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​(java.lang.String key, int exp, T value, Transcoder<T> transcoder)  
      protected Session sendCommand​(Command cmd)  
      private <T> Command sendGetMultiCommand​(java.util.Collection<java.lang.String> keys, java.util.concurrent.CountDownLatch latch, CommandType cmdType, Transcoder<T> transcoder)  
      private long sendIncrOrDecrCommand​(java.lang.String key, long delta, long initValue, CommandType cmdType, boolean noreply, long operationTimeout, int exp)  
      private <T> boolean sendStoreCommand​(Command command, long timeout)  
      boolean set​(java.lang.String key, int exp, java.lang.Object value)  
      boolean set​(java.lang.String key, int exp, java.lang.Object value, long timeout)  
      <T> boolean set​(java.lang.String key, int exp, T value, Transcoder<T> transcoder)  
      <T> boolean set​(java.lang.String key, int exp, T value, Transcoder<T> transcoder, long timeout)
      Store key-value item to memcached
      void setAuthInfoMap​(java.util.Map<java.net.InetSocketAddress,​AuthInfo> map)
      Configure auth info
      void setBufferAllocator​(BufferAllocator bufferAllocator)
      Set the nio's ByteBuffer Allocator,use SimpleBufferAllocator by default.
      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​(java.net.InetSocketAddress address, int level)
      Set the verbosity level of the memcached's logging output.This method will wait for reply.
      void setLoggingLevelVerbosityWithNoReply​(java.net.InetSocketAddress address, int level)
      Set the verbosity level of the memcached's logging output.This method doesn't wait for reply from server
      (package private) void setMaxQueuedNoReplyOperations​(int maxQueuedNoReplyOperations)
      Set max queued noreply operations number
      private void setMemcachedLoggingLevel​(java.net.InetSocketAddress address, int level, boolean noreply)  
      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​(java.lang.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 sanitizeKeys)
      Enables/disables sanitizing keys by URLEncoding.
      void setServerWeight​(java.lang.String server, int weight)
      Set a memcached server's weight
      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​(java.lang.String key, int exp, java.lang.Object value)
      Store key-value item to memcached,doesn't wait for reply
      <T> void setWithNoReply​(java.lang.String key, int exp, T value, Transcoder<T> transcoder)  
      void shutdown()  
      protected void shutdown0()
      For subclass override.
      private void start0()  
      private void startConnector()  
      java.util.Map<java.lang.String,​java.lang.String> stats​(java.net.InetSocketAddress address)  
      java.util.Map<java.lang.String,​java.lang.String> stats​(java.net.InetSocketAddress address, long timeout)
      �ョ��瑰������emcached server缁��淇℃�
      boolean touch​(java.lang.String key, int exp)
      Set a new expiration time for an existing item,using default opTimeout second.
      boolean touch​(java.lang.String key, int exp, long opTimeout)
      Set a new expiration time for an existing item
      <T> T withNamespace​(java.lang.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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • log

        private static final org.slf4j.Logger log
      • shutdown

        private volatile boolean shutdown
      • sanitizeKeys

        private boolean sanitizeKeys
      • opTimeout

        protected long opTimeout
      • connectTimeout

        private long connectTimeout
      • connectionPoolSize

        protected int connectionPoolSize
      • maxQueuedNoReplyOperations

        protected int maxQueuedNoReplyOperations
      • resolveInetAddresses

        protected boolean resolveInetAddresses
      • serverOrderCount

        protected final java.util.concurrent.atomic.AtomicInteger serverOrderCount
      • authInfoMap

        private java.util.Map<java.net.InetSocketAddress,​AuthInfo> authInfoMap
      • authInfoStringMap

        private java.util.Map<java.lang.String,​AuthInfo> authInfoStringMap
      • name

        private java.lang.String name
      • failureMode

        private boolean failureMode
      • timeoutExceptionThreshold

        private int timeoutExceptionThreshold
      • shutdownHookThread

        private java.lang.Thread shutdownHookThread
      • isHutdownHookCalled

        private volatile boolean isHutdownHookCalled
      • NAMESPACE_LOCAL

        public static final java.lang.ThreadLocal<java.lang.String> NAMESPACE_LOCAL
        namespace thread local.
      • CONTINUOUS_TIMEOUT_COUNTER

        private static final java.lang.String CONTINUOUS_TIMEOUT_COUNTER
        See Also:
        Constant Field Values
    • Constructor Detail

      • XMemcachedClient

        public XMemcachedClient​(java.lang.String server,
                                int port)
                         throws java.io.IOException
        XMemcached constructor,default weight is 1
        Parameters:
        server - �����P
        port - ����ㄧ���
        Throws:
        java.io.IOException
      • XMemcachedClient

        public XMemcachedClient​(java.lang.String host,
                                int port,
                                int weight)
                         throws java.io.IOException
        XMemcached constructor
        Parameters:
        host - server host
        port - server port
        weight - server weight
        Throws:
        java.io.IOException
      • XMemcachedClient

        public XMemcachedClient​(java.net.InetSocketAddress inetSocketAddress,
                                int weight,
                                CommandFactory cmdFactory)
                         throws java.io.IOException
        XMemcached Constructor.
        Parameters:
        inetSocketAddress -
        weight -
        Throws:
        java.io.IOException
      • XMemcachedClient

        public XMemcachedClient​(java.net.InetSocketAddress inetSocketAddress,
                                int weight)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • XMemcachedClient

        public XMemcachedClient​(java.net.InetSocketAddress inetSocketAddress)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • XMemcachedClient

        public XMemcachedClient()
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • XMemcachedClient

        public XMemcachedClient​(MemcachedSessionLocator locator,
                                MemcachedSessionComparator comparator,
                                BufferAllocator allocator,
                                Configuration conf,
                                java.util.Map<SocketOption,​java.lang.Object> socketOptions,
                                CommandFactory commandFactory,
                                Transcoder transcoder,
                                java.util.Map<java.net.InetSocketAddress,​java.net.InetSocketAddress> addressMap,
                                java.util.List<MemcachedClientStateListener> stateListeners,
                                java.util.Map<java.net.InetSocketAddress,​AuthInfo> map,
                                int poolSize,
                                long connectTimeout,
                                java.lang.String name,
                                boolean failureMode,
                                boolean resolveInetAddresses)
                         throws java.io.IOException
        XMemcachedClient constructor.Every server's weight is one by default. You should not new client instance by this method, use MemcachedClientBuilder instead.
        Parameters:
        locator -
        comparator -
        allocator -
        conf -
        commandFactory -
        transcoder -
        addressList -
        stateListeners -
        Throws:
        java.io.IOException
      • XMemcachedClient

        XMemcachedClient​(MemcachedSessionLocator locator,
                         MemcachedSessionComparator comparator,
                         BufferAllocator allocator,
                         Configuration conf,
                         java.util.Map<SocketOption,​java.lang.Object> socketOptions,
                         CommandFactory commandFactory,
                         Transcoder transcoder,
                         java.util.Map<java.net.InetSocketAddress,​java.net.InetSocketAddress> addressMap,
                         int[] weights,
                         java.util.List<MemcachedClientStateListener> stateListeners,
                         java.util.Map<java.net.InetSocketAddress,​AuthInfo> infoMap,
                         int poolSize,
                         long connectTimeout,
                         java.lang.String name,
                         boolean failureMode,
                         boolean resolveInetAddresses)
                  throws java.io.IOException
        XMemcachedClient constructor.
        Parameters:
        locator -
        comparator -
        allocator -
        conf -
        commandFactory -
        transcoder -
        addressList -
        weights -
        stateListeners - weight array for address list
        Throws:
        java.io.IOException
      • XMemcachedClient

        public XMemcachedClient​(java.util.List<java.net.InetSocketAddress> addressList)
                         throws java.io.IOException
        XMemcached Constructor.Every server's weight is one by default.
        Parameters:
        addressList -
        Throws:
        java.io.IOException
      • XMemcachedClient

        public XMemcachedClient​(java.util.List<java.net.InetSocketAddress> addressList,
                                CommandFactory cmdFactory)
                         throws java.io.IOException
        XMemcached Constructor.Every server's weight is one by default.
        Parameters:
        cmdFactory - command factory
        addressList - memcached server socket address list.
        Throws:
        java.io.IOException
    • Method Detail

      • setMergeFactor

        public final void setMergeFactor​(int mergeFactor)
        Description copied from interface: MemcachedClient
        Set the merge factor,this factor determins how many 'get' commands would be merge to one multi-get command.default is 150
        Specified by:
        setMergeFactor in interface MemcachedClient
      • setName

        public void setName​(java.lang.String name)
        Description copied from interface: MemcachedClient
        Set cache instance name
        Specified by:
        setName in interface MemcachedClient
      • setConnectTimeout

        public void setConnectTimeout​(long connectTimeout)
        Description copied from interface: MemcachedClient
        Set the connect timeout,default is 1 minutes
        Specified by:
        setConnectTimeout in interface MemcachedClient
      • setEnableHeartBeat

        public void setEnableHeartBeat​(boolean enableHeartBeat)
        Description copied from interface: MemcachedClient
        Whether to enable heart beat
        Specified by:
        setEnableHeartBeat in interface MemcachedClient
        Parameters:
        enableHeartBeat - if true,then enable heartbeat,true by default
      • getOpTimeout

        public final long getOpTimeout()
        get operation timeout setting
        Specified by:
        getOpTimeout in interface MemcachedClient
        Returns:
      • setOpTimeout

        public final void setOpTimeout​(long opTimeout)
        set operation timeout,default is one second.
        Specified by:
        setOpTimeout in interface MemcachedClient
        Parameters:
        opTimeout -
      • setHealSessionInterval

        public void setHealSessionInterval​(long healConnectionInterval)
        Description copied from interface: MemcachedClient
        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.
        Specified by:
        setHealSessionInterval in interface MemcachedClient
        Parameters:
        healConnectionInterval - MILLISECONDS
      • getAuthInfoMap

        public java.util.Map<java.net.InetSocketAddress,​AuthInfo> getAuthInfoMap()
        Description copied from interface: MemcachedClient
        return current all auth info
        Specified by:
        getAuthInfoMap in interface MemcachedClient
        Returns:
        Auth info map,key is memcached server address,and value is the auth info for the key.
      • setAuthInfoMap

        public void setAuthInfoMap​(java.util.Map<java.net.InetSocketAddress,​AuthInfo> map)
        Description copied from interface: MemcachedClient
        Configure auth info
        Specified by:
        setAuthInfoMap in interface MemcachedClient
        Parameters:
        map - Auth info map,key is memcached server address,and value is the auth info for the key.
      • getAuthInfoStringMap

        public java.util.Map<java.lang.String,​AuthInfo> getAuthInfoStringMap()
        Description copied from interface: MemcachedClient
        Retruns the AuthInfo for all server strings (hostname:port)
        Specified by:
        getAuthInfoStringMap in interface MemcachedClient
        Returns:
        A map of AuthInfos for server strings (hostname:port)
      • setOptimizeMergeBuffer

        public final void setOptimizeMergeBuffer​(boolean optimizeMergeBuffer)
        Description copied from interface: MemcachedClient
        Enable/Disable merge many command's buffers to one big buffer fit socket's send buffer size.Default is true.Recommend true.
        Specified by:
        setOptimizeMergeBuffer in interface MemcachedClient
      • gets0

        private final <T> GetsResponse<T> gets0​(java.lang.String key,
                                                byte[] keyBytes,
                                                Transcoder<T> transcoder)
                                         throws MemcachedException,
                                                java.util.concurrent.TimeoutException,
                                                java.lang.InterruptedException
        Throws:
        MemcachedException
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
      • newSocketAddress

        protected java.net.InetSocketAddress newSocketAddress​(java.lang.String server,
                                                              int port)
      • checkServerPort

        private void checkServerPort​(java.lang.String server,
                                     int port)
      • addServer

        public final void addServer​(java.lang.String server,
                                    int port)
                             throws java.io.IOException
        Description copied from interface: MemcachedClient
        Aadd a memcached server,the thread call this method will be blocked until the connecting operations completed(success or fail)
        Specified by:
        addServer in interface MemcachedClient
        Parameters:
        server - host string
        port - port number
        Throws:
        java.io.IOException
      • addServer

        public final void addServer​(java.lang.String server,
                                    int port,
                                    int weight)
                             throws java.io.IOException
        add a memcached server to MemcachedClient
        Specified by:
        addServer in interface MemcachedClient
        Parameters:
        server -
        port -
        weight -
        Throws:
        java.io.IOException
      • addServer

        public final void addServer​(java.net.InetSocketAddress inetSocketAddress)
                             throws java.io.IOException
        Description copied from interface: MemcachedClient
        Add a memcached server,the thread call this method will be blocked until the connecting operations completed(success or fail)
        Specified by:
        addServer in interface MemcachedClient
        Parameters:
        inetSocketAddress - memcached server's socket address
        Throws:
        java.io.IOException
      • addServer

        public final void addServer​(java.net.InetSocketAddress inetSocketAddress,
                                    int weight)
                             throws java.io.IOException
        Specified by:
        addServer in interface MemcachedClient
        Throws:
        java.io.IOException
      • addOneServerWithWeight

        public void addOneServerWithWeight​(java.lang.String server,
                                           int weight)
                                    throws java.io.IOException
        Description copied from interface: XMemcachedClientMBean
        Add a memcached server
        Specified by:
        addOneServerWithWeight in interface XMemcachedClientMBean
        Parameters:
        server - a String in the form of "[host1]:[port1],[host2]:[port2]"
        weight - server's weight
        Throws:
        java.io.IOException
      • removeServer

        public void removeServer​(java.net.InetSocketAddress address)
        Description copied from interface: MemcachedClient
        Remove memcached server with the exact given address.
        Specified by:
        removeServer in interface MemcachedClient
        Parameters:
        address - Resolved server address
      • connect

        protected void connect​(InetSocketAddressWrapper inetSocketAddressWrapper)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • fetch0

        private final <T> java.lang.Object fetch0​(java.lang.String key,
                                                  byte[] keyBytes,
                                                  CommandType cmdType,
                                                  long timeout,
                                                  Transcoder<T> transcoder)
                                           throws java.lang.InterruptedException,
                                                  java.util.concurrent.TimeoutException,
                                                  MemcachedException
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
        MemcachedException
      • start0

        private final void start0()
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • startConnector

        private final void startConnector()
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • setMaxQueuedNoReplyOperations

        void setMaxQueuedNoReplyOperations​(int maxQueuedNoReplyOperations)
        Set max queued noreply operations number
        Parameters:
        maxQueuedNoReplyOperations -
      • registerMBean

        private final void registerMBean()
      • setOptimizeGet

        public void setOptimizeGet​(boolean optimizeGet)
        Description copied from interface: MemcachedClient
        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.
        Specified by:
        setOptimizeGet in interface MemcachedClient
      • optimiezeSetReadThreadCount

        private final void optimiezeSetReadThreadCount​(Configuration conf,
                                                       int addressCount)
      • isWindowsPlatform

        private final boolean isWindowsPlatform()
      • get

        public final <T> T get​(java.lang.String key,
                               long timeout,
                               Transcoder<T> transcoder)
                        throws java.util.concurrent.TimeoutException,
                               java.lang.InterruptedException,
                               MemcachedException
        Description copied from interface: MemcachedClient
        Get value by key
        Specified by:
        get in interface MemcachedClient
        Parameters:
        key - Key
        timeout - Operation timeout,if the method is not returned in this time,throw TimeoutException
        transcoder - The value's transcoder
        Returns:
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • get

        public final <T> T get​(java.lang.String key,
                               long timeout)
                        throws java.util.concurrent.TimeoutException,
                               java.lang.InterruptedException,
                               MemcachedException
        Specified by:
        get in interface MemcachedClient
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • get

        public final <T> T get​(java.lang.String key,
                               Transcoder<T> transcoder)
                        throws java.util.concurrent.TimeoutException,
                               java.lang.InterruptedException,
                               MemcachedException
        Specified by:
        get in interface MemcachedClient
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • get

        public final <T> T get​(java.lang.String key)
                        throws java.util.concurrent.TimeoutException,
                               java.lang.InterruptedException,
                               MemcachedException
        Specified by:
        get in interface MemcachedClient
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • get0

        private <T> java.lang.Object get0​(java.lang.String key,
                                          long timeout,
                                          CommandType cmdType,
                                          Transcoder<T> transcoder)
                                   throws java.util.concurrent.TimeoutException,
                                          java.lang.InterruptedException,
                                          MemcachedException
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • gets

        public final <T> GetsResponse<T> gets​(java.lang.String key,
                                              long timeout,
                                              Transcoder<T> transcoder)
                                       throws java.util.concurrent.TimeoutException,
                                              java.lang.InterruptedException,
                                              MemcachedException
        Description copied from interface: MemcachedClient
        Just like get,But it return a GetsResponse,include cas value for cas update.
        Specified by:
        gets in interface MemcachedClient
        Parameters:
        key - key
        timeout - operation timeout
        Returns:
        GetsResponse
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • get

        public final <T> java.util.Map<java.lang.String,​T> get​(java.util.Collection<java.lang.String> keyCollections,
                                                                     long timeout,
                                                                     Transcoder<T> transcoder)
                                                              throws java.util.concurrent.TimeoutException,
                                                                     java.lang.InterruptedException,
                                                                     MemcachedException
        Description copied from interface: MemcachedClient
        Bulk get items
        Specified by:
        get in interface MemcachedClient
        Parameters:
        keyCollections - key collection
        timeout - opTimeout
        transcoder - Value transcoder
        Returns:
        Exists items map
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • gets

        public final <T> java.util.Map<java.lang.String,​GetsResponse<T>> gets​(java.util.Collection<java.lang.String> keyCollections,
                                                                                    long timeout,
                                                                                    Transcoder<T> transcoder)
                                                                             throws java.util.concurrent.TimeoutException,
                                                                                    java.lang.InterruptedException,
                                                                                    MemcachedException
        Description copied from interface: MemcachedClient
        Bulk gets items
        Specified by:
        gets in interface MemcachedClient
        Parameters:
        keyCollections - key collection
        timeout - Operation timeout
        transcoder - Value transcoder
        Returns:
        Exists GetsResponse map
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
        See Also:
        GetsResponse
      • getMulti0

        private final <T> java.util.Map<java.lang.String,​T> getMulti0​(java.util.Collection<java.lang.String> keys,
                                                                            long timeout,
                                                                            CommandType cmdType,
                                                                            Transcoder<T> transcoder)
                                                                     throws java.util.concurrent.TimeoutException,
                                                                            java.lang.InterruptedException,
                                                                            MemcachedException
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • reduceResult

        private <T> java.util.Map<java.lang.String,​T> reduceResult​(CommandType cmdType,
                                                                         Transcoder<T> transcoder,
                                                                         java.util.List<Command> commands)
                                                                  throws MemcachedException,
                                                                         java.lang.InterruptedException,
                                                                         java.util.concurrent.TimeoutException
        Throws:
        MemcachedException
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
      • catalogKeys

        private final java.util.Collection<java.util.List<java.lang.String>> catalogKeys​(java.util.Collection<java.lang.String> keyCollections)
        Hash key to servers
        Parameters:
        keyCollections -
        Returns:
      • sendGetMultiCommand

        private final <T> Command sendGetMultiCommand​(java.util.Collection<java.lang.String> keys,
                                                      java.util.concurrent.CountDownLatch latch,
                                                      CommandType cmdType,
                                                      Transcoder<T> transcoder)
                                               throws java.lang.InterruptedException,
                                                      java.util.concurrent.TimeoutException,
                                                      MemcachedException
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
        MemcachedException
      • set

        public final <T> boolean set​(java.lang.String key,
                                     int exp,
                                     T value,
                                     Transcoder<T> transcoder,
                                     long timeout)
                              throws java.util.concurrent.TimeoutException,
                                     java.lang.InterruptedException,
                                     MemcachedException
        Description copied from interface: MemcachedClient
        Store key-value item to memcached
        Specified by:
        set in interface MemcachedClient
        Parameters:
        key - stored 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 - stored data
        transcoder - transocder
        timeout - operation timeout,in milliseconds
        Returns:
        boolean result
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • setWithNoReply

        public void setWithNoReply​(java.lang.String key,
                                   int exp,
                                   java.lang.Object value)
                            throws java.lang.InterruptedException,
                                   MemcachedException
        Description copied from interface: MemcachedClient
        Store key-value item to memcached,doesn't wait for reply
        Specified by:
        setWithNoReply in interface MemcachedClient
        Parameters:
        key - stored 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 - stored data
        Throws:
        java.lang.InterruptedException
        MemcachedException
      • checkStoreArguments

        private final <T> byte[] checkStoreArguments​(java.lang.String key,
                                                     int exp,
                                                     T value)
      • add

        public final <T> boolean add​(java.lang.String key,
                                     int exp,
                                     T value,
                                     Transcoder<T> transcoder,
                                     long timeout)
                              throws java.util.concurrent.TimeoutException,
                                     java.lang.InterruptedException,
                                     MemcachedException
        Description copied from interface: MemcachedClient
        Add key-value item to memcached, success only when the key is not exists in memcached.
        Specified by:
        add in interface MemcachedClient
        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.
        Returns:
        boolean result
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • add0

        private <T> boolean add0​(java.lang.String key,
                                 int exp,
                                 T value,
                                 Transcoder<T> transcoder,
                                 long timeout)
                          throws java.lang.InterruptedException,
                                 java.util.concurrent.TimeoutException,
                                 MemcachedException
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
        MemcachedException
      • addWithNoReply

        public void addWithNoReply​(java.lang.String key,
                                   int exp,
                                   java.lang.Object value)
                            throws java.lang.InterruptedException,
                                   MemcachedException
        Description copied from interface: MemcachedClient
        Add key-value item to memcached, success only when the key is not exists in memcached.This method doesn't wait for reply.
        Specified by:
        addWithNoReply in interface MemcachedClient
        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.
        Throws:
        java.lang.InterruptedException
        MemcachedException
      • replaceWithNoReply

        public void replaceWithNoReply​(java.lang.String key,
                                       int exp,
                                       java.lang.Object value)
                                throws java.lang.InterruptedException,
                                       MemcachedException
        Description copied from interface: MemcachedClient
        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.
        Specified by:
        replaceWithNoReply in interface MemcachedClient
        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.
        Throws:
        java.lang.InterruptedException
        MemcachedException
      • replace

        public final <T> boolean replace​(java.lang.String key,
                                         int exp,
                                         T value,
                                         Transcoder<T> transcoder,
                                         long timeout)
                                  throws java.util.concurrent.TimeoutException,
                                         java.lang.InterruptedException,
                                         MemcachedException
        Description copied from interface: MemcachedClient
        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.
        Specified by:
        replace in interface MemcachedClient
        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.
        Returns:
        boolean result
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • append

        public final boolean append​(java.lang.String key,
                                    java.lang.Object value,
                                    long timeout)
                             throws java.util.concurrent.TimeoutException,
                                    java.lang.InterruptedException,
                                    MemcachedException
        Description copied from interface: MemcachedClient
        Append value to key's data item,this method will wait for reply
        Specified by:
        append in interface MemcachedClient
        Returns:
        boolean result
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • prepend

        public final boolean prepend​(java.lang.String key,
                                     java.lang.Object value,
                                     long timeout)
                              throws java.util.concurrent.TimeoutException,
                                     java.lang.InterruptedException,
                                     MemcachedException
        Description copied from interface: MemcachedClient
        Prepend value to key's data item in memcached.This method doesn't wait for reply.
        Specified by:
        prepend in interface MemcachedClient
        Returns:
        boolean result
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • cas

        public final <T> boolean cas​(java.lang.String key,
                                     int exp,
                                     T value,
                                     Transcoder<T> transcoder,
                                     long timeout,
                                     long cas)
                              throws java.util.concurrent.TimeoutException,
                                     java.lang.InterruptedException,
                                     MemcachedException
        Description copied from interface: MemcachedClient
        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."
        Specified by:
        cas in interface MemcachedClient
        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.
        Returns:
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • cas0

        private final <T> boolean cas0​(java.lang.String key,
                                       int exp,
                                       GetsResponse<T> getsResponse,
                                       CASOperation<T> operation,
                                       Transcoder<T> transcoder,
                                       byte[] keyBytes,
                                       boolean noreply)
                                throws java.util.concurrent.TimeoutException,
                                       java.lang.InterruptedException,
                                       MemcachedException
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • cas

        public final <T> boolean cas​(java.lang.String key,
                                     int exp,
                                     CASOperation<T> operation,
                                     Transcoder<T> transcoder)
                              throws java.util.concurrent.TimeoutException,
                                     java.lang.InterruptedException,
                                     MemcachedException
        Description copied from interface: MemcachedClient
        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."
        Specified by:
        cas in interface MemcachedClient
        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 - CASOperation
        transcoder - object transcoder
        Returns:
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • cas

        public final <T> boolean cas​(java.lang.String key,
                                     int exp,
                                     GetsResponse<T> getsReponse,
                                     CASOperation<T> operation,
                                     Transcoder<T> transcoder)
                              throws java.util.concurrent.TimeoutException,
                                     java.lang.InterruptedException,
                                     MemcachedException
        Description copied from interface: MemcachedClient
        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."
        Specified by:
        cas in interface MemcachedClient
        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 result
        operation - CASOperation
        Returns:
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • delete

        public final boolean delete​(java.lang.String key,
                                    int time)
                             throws java.util.concurrent.TimeoutException,
                                    java.lang.InterruptedException,
                                    MemcachedException
        Description copied from interface: MemcachedClient
        Delete key's data item from memcached.It it is not exists,return false.
        time is the amount of time in seconds (or Unix time until
        which) the client wishes the server to refuse "add" and "replace"
        commands with this key. For this amount of item, the item is put into a
        delete queue, which means that it won't possible to retrieve it by the
        "get" command, but "add" and "replace" command with this key will also
        fail (the "set" command will succeed, however). After the time passes,
        the item is finally deleted from server memory.
        Note: This method is deprecated,because memcached 1.4.0 remove the optional argument "time".You can still use this method on old version,but is not recommended.
        Specified by:
        delete in interface MemcachedClient
        Throws:
        java.lang.InterruptedException
        MemcachedException
        java.util.concurrent.TimeoutException
      • delete

        public boolean delete​(java.lang.String key,
                              long opTimeout)
                       throws java.util.concurrent.TimeoutException,
                              java.lang.InterruptedException,
                              MemcachedException
        Description copied from interface: MemcachedClient
        Delete key's date item from memcached
        Specified by:
        delete in interface MemcachedClient
        opTimeout - Operation timeout
        Returns:
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • delete

        public boolean delete​(java.lang.String key,
                              long cas,
                              long opTimeout)
                       throws java.util.concurrent.TimeoutException,
                              java.lang.InterruptedException,
                              MemcachedException
        Description copied from interface: MemcachedClient
        Delete key's date item from memcached only if its cas value is the same as what was read.
        Specified by:
        delete in interface MemcachedClient
        opTimeout - Operation timeout
        Returns:
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • deleteWithNoReply

        public final void deleteWithNoReply​(java.lang.String key,
                                            int time)
                                     throws java.lang.InterruptedException,
                                            MemcachedException
        Delete key's data item from memcached.This method doesn't wait for reply
        Specified by:
        deleteWithNoReply in interface MemcachedClient
        Parameters:
        key -
        time -
        Throws:
        java.lang.InterruptedException
        MemcachedException
      • delete0

        private boolean delete0​(java.lang.String key,
                                int time,
                                long cas,
                                boolean noreply,
                                long opTimeout)
                         throws MemcachedException,
                                java.lang.InterruptedException,
                                java.util.concurrent.TimeoutException
        Throws:
        MemcachedException
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
      • touch

        public boolean touch​(java.lang.String key,
                             int exp,
                             long opTimeout)
                      throws java.util.concurrent.TimeoutException,
                             java.lang.InterruptedException,
                             MemcachedException
        Description copied from interface: MemcachedClient
        Set a new expiration time for an existing item
        Specified by:
        touch in interface MemcachedClient
        Parameters:
        key - item's key
        exp - 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 timeout
        Returns:
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • touch

        public boolean touch​(java.lang.String key,
                             int exp)
                      throws java.util.concurrent.TimeoutException,
                             java.lang.InterruptedException,
                             MemcachedException
        Description copied from interface: MemcachedClient
        Set a new expiration time for an existing item,using default opTimeout second.
        Specified by:
        touch in interface MemcachedClient
        Parameters:
        key - item's key
        exp - New expiration time, in seconds. Can be up to 30 days. After 30 days, is treated as a unix timestamp of an exact date.
        Returns:
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • getAndTouch

        public <T> T getAndTouch​(java.lang.String key,
                                 int newExp,
                                 long opTimeout)
                          throws java.util.concurrent.TimeoutException,
                                 java.lang.InterruptedException,
                                 MemcachedException
        Description copied from interface: MemcachedClient
        Get item and set a new expiration time for it
        Specified by:
        getAndTouch in interface MemcachedClient
        Parameters:
        key - item's key
        newExp - 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 timeout
        Returns:
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • getAndTouch

        public <T> T getAndTouch​(java.lang.String key,
                                 int newExp)
                          throws java.util.concurrent.TimeoutException,
                                 java.lang.InterruptedException,
                                 MemcachedException
        Description copied from interface: MemcachedClient
        Get item and set a new expiration time for it,using default opTimeout
        Specified by:
        getAndTouch in interface MemcachedClient
        Returns:
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • incr

        public final long incr​(java.lang.String key,
                               long delta)
                        throws java.util.concurrent.TimeoutException,
                               java.lang.InterruptedException,
                               MemcachedException
        Description copied from interface: MemcachedClient
        "incr" are used to change data for some item in-place, incrementing it. The data for the item is treated as decimal representation of a 64-bit unsigned integer. If the current data value does not conform to such a representation, the commands behave as if the value were 0. Also, the item must already exist for incr to work; these commands won't pretend that a non-existent key exists with value 0; instead, it will fail.This method doesn't wait for reply.
        Specified by:
        incr in interface MemcachedClient
        Returns:
        the new value of the item's data, after the increment operation was carried out.
        Throws:
        java.lang.InterruptedException
        MemcachedException
        java.util.concurrent.TimeoutException
      • incr

        public long incr​(java.lang.String key,
                         long delta,
                         long initValue)
                  throws java.util.concurrent.TimeoutException,
                         java.lang.InterruptedException,
                         MemcachedException
        Specified by:
        incr in interface MemcachedClient
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • incr

        public long incr​(java.lang.String key,
                         long delta,
                         long initValue,
                         long timeout)
                  throws java.util.concurrent.TimeoutException,
                         java.lang.InterruptedException,
                         MemcachedException
        Description copied from interface: MemcachedClient
        "incr" are used to change data for some item in-place, incrementing it. The data for the item is treated as decimal representation of a 64-bit unsigned integer. If the current data value does not conform to such a representation, the commands behave as if the value were 0. Also, the item must already exist for incr to work; these commands won't pretend that a non-existent key exists with value 0; instead, it will fail.This method doesn't wait for reply.
        Specified by:
        incr in interface MemcachedClient
        Parameters:
        key - key
        initValue - initValue if the data is not exists.
        timeout - operation timeout
        Returns:
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • incr

        public long incr​(java.lang.String key,
                         long delta,
                         long initValue,
                         long timeout,
                         int exp)
                  throws java.util.concurrent.TimeoutException,
                         java.lang.InterruptedException,
                         MemcachedException
        Description copied from interface: MemcachedClient
        "incr" are used to change data for some item in-place, incrementing it. The data for the item is treated as decimal representation of a 64-bit unsigned integer. If the current data value does not conform to such a representation, the commands behave as if the value were 0. Also, the item must already exist for incr to work; these commands won't pretend that a non-existent key exists with value 0; instead, it will fail.This method doesn't wait for reply.
        Specified by:
        incr in interface MemcachedClient
        Parameters:
        key - key
        delta - increment delta
        initValue - the initial value to be added when value is not found
        timeout - operation timeout
        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.
        Returns:
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • incrWithNoReply

        public final void incrWithNoReply​(java.lang.String key,
                                          long delta)
                                   throws java.lang.InterruptedException,
                                          MemcachedException
        Description copied from interface: MemcachedClient
        "incr" are used to change data for some item in-place, incrementing it. The data for the item is treated as decimal representation of a 64-bit unsigned integer. If the current data value does not conform to such a representation, the commands behave as if the value were 0. Also, the item must already exist for incr to work; these commands won't pretend that a non-existent key exists with value 0; instead, it will fail.This method doesn't wait for reply.
        Specified by:
        incrWithNoReply in interface MemcachedClient
        Throws:
        java.lang.InterruptedException
        MemcachedException
      • decrWithNoReply

        public final void decrWithNoReply​(java.lang.String key,
                                          long delta)
                                   throws java.lang.InterruptedException,
                                          MemcachedException
        Description copied from interface: MemcachedClient
        "decr" are used to change data for some item in-place, decrementing it. The data for the item is treated as decimal representation of a 64-bit unsigned integer. If the current data value does not conform to such a representation, the commands behave as if the value were 0. Also, the item must already exist for decr to work; these commands won't pretend that a non-existent key exists with value 0; instead, it will fail.This method doesn't wait for reply.
        Specified by:
        decrWithNoReply in interface MemcachedClient
        Throws:
        java.lang.InterruptedException
        MemcachedException
      • decr

        public final long decr​(java.lang.String key,
                               long delta)
                        throws java.util.concurrent.TimeoutException,
                               java.lang.InterruptedException,
                               MemcachedException
        Description copied from interface: MemcachedClient
        "decr" are used to change data for some item in-place, decrementing it. The data for the item is treated as decimal representation of a 64-bit unsigned integer. If the current data value does not conform to such a representation, the commands behave as if the value were 0. Also, the item must already exist for decr to work; these commands won't pretend that a non-existent key exists with value 0; instead, it will fail.This method doesn't wait for reply.
        Specified by:
        decr in interface MemcachedClient
        Returns:
        the new value of the item's data, after the decrement operation was carried out.
        Throws:
        java.lang.InterruptedException
        MemcachedException
        java.util.concurrent.TimeoutException
      • decr

        public long decr​(java.lang.String key,
                         long delta,
                         long initValue,
                         long timeout)
                  throws java.util.concurrent.TimeoutException,
                         java.lang.InterruptedException,
                         MemcachedException
        Description copied from interface: MemcachedClient
        "decr" are used to change data for some item in-place, decrementing it. The data for the item is treated as decimal representation of a 64-bit unsigned integer. If the current data value does not conform to such a representation, the commands behave as if the value were 0. Also, the item must already exist for decr to work; these commands won't pretend that a non-existent key exists with value 0; instead, it will fail.This method doesn't wait for reply.
        Specified by:
        decr in interface MemcachedClient
        Parameters:
        key - The key
        initValue - The initial value if the data is not exists.
        timeout - Operation timeout
        Returns:
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • decr

        public long decr​(java.lang.String key,
                         long delta,
                         long initValue,
                         long timeout,
                         int exp)
                  throws java.util.concurrent.TimeoutException,
                         java.lang.InterruptedException,
                         MemcachedException
        Description copied from interface: MemcachedClient
        "incr" are used to change data for some item in-place, incrementing it. The data for the item is treated as decimal representation of a 64-bit unsigned integer. If the current data value does not conform to such a representation, the commands behave as if the value were 0. Also, the item must already exist for incr to work; these commands won't pretend that a non-existent key exists with value 0; instead, it will fail.This method doesn't wait for reply.
        Specified by:
        decr in interface MemcachedClient
        initValue - the initial value to be added when value is not found
        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.
        Returns:
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • flushAll

        public final void flushAll()
                            throws java.util.concurrent.TimeoutException,
                                   java.lang.InterruptedException,
                                   MemcachedException
        Description copied from interface: MemcachedClient
        Make All connected memcached's data item invalid
        Specified by:
        flushAll in interface MemcachedClient
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • flushAll

        public final void flushAll​(int exptime,
                                   long timeout)
                            throws java.util.concurrent.TimeoutException,
                                   java.lang.InterruptedException,
                                   MemcachedException
        Specified by:
        flushAll in interface MemcachedClient
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • flushAll

        public final void flushAll​(long timeout)
                            throws java.util.concurrent.TimeoutException,
                                   java.lang.InterruptedException,
                                   MemcachedException
        Description copied from interface: MemcachedClient
        Make All connected memcached's data item invalid
        Specified by:
        flushAll in interface MemcachedClient
        Parameters:
        timeout - operation timeout
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • flushAllMemcachedServers

        private void flushAllMemcachedServers​(long timeout,
                                              boolean noreply,
                                              int exptime)
                                       throws MemcachedException,
                                              java.lang.InterruptedException,
                                              java.util.concurrent.TimeoutException
        Throws:
        MemcachedException
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
      • setLoggingLevelVerbosity

        public void setLoggingLevelVerbosity​(java.net.InetSocketAddress address,
                                             int level)
                                      throws java.util.concurrent.TimeoutException,
                                             java.lang.InterruptedException,
                                             MemcachedException
        Description copied from interface: MemcachedClient
        Set the verbosity level of the memcached's logging output.This method will wait for reply.
        Specified by:
        setLoggingLevelVerbosity in interface MemcachedClient
        level - logging level
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • setMemcachedLoggingLevel

        private void setMemcachedLoggingLevel​(java.net.InetSocketAddress address,
                                              int level,
                                              boolean noreply)
                                       throws MemcachedException,
                                              java.lang.InterruptedException,
                                              java.util.concurrent.TimeoutException
        Throws:
        MemcachedException
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
      • setLoggingLevelVerbosityWithNoReply

        public void setLoggingLevelVerbosityWithNoReply​(java.net.InetSocketAddress address,
                                                        int level)
                                                 throws java.lang.InterruptedException,
                                                        MemcachedException
        Description copied from interface: MemcachedClient
        Set the verbosity level of the memcached's logging output.This method doesn't wait for reply from server
        Specified by:
        setLoggingLevelVerbosityWithNoReply in interface MemcachedClient
        Parameters:
        address - memcached server address
        level - logging level
        Throws:
        java.lang.InterruptedException
        MemcachedException
      • flushAll

        public final void flushAll​(java.net.InetSocketAddress address)
                            throws MemcachedException,
                                   java.lang.InterruptedException,
                                   java.util.concurrent.TimeoutException
        Description copied from interface: MemcachedClient
        Invalidate all existing items immediately
        Specified by:
        flushAll in interface MemcachedClient
        Parameters:
        address - Target memcached server
        Throws:
        MemcachedException
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
      • flushAll

        public final void flushAll​(java.net.InetSocketAddress address,
                                   long timeout)
                            throws MemcachedException,
                                   java.lang.InterruptedException,
                                   java.util.concurrent.TimeoutException
        Specified by:
        flushAll in interface MemcachedClient
        Throws:
        MemcachedException
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
      • flushAll

        public final void flushAll​(java.net.InetSocketAddress address,
                                   long timeout,
                                   int exptime)
                            throws MemcachedException,
                                   java.lang.InterruptedException,
                                   java.util.concurrent.TimeoutException
        Specified by:
        flushAll in interface MemcachedClient
        Throws:
        MemcachedException
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
      • flushSpecialMemcachedServer

        private void flushSpecialMemcachedServer​(java.net.InetSocketAddress address,
                                                 long timeout,
                                                 boolean noreply,
                                                 int exptime)
                                          throws MemcachedException,
                                                 java.lang.InterruptedException,
                                                 java.util.concurrent.TimeoutException
        Throws:
        MemcachedException
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
      • flushAll

        public final void flushAll​(java.lang.String host)
                            throws java.util.concurrent.TimeoutException,
                                   java.lang.InterruptedException,
                                   MemcachedException
        Description copied from interface: MemcachedClient
        This method is deprecated,please use flushAll(InetSocketAddress) instead.
        Specified by:
        flushAll in interface MemcachedClient
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • stats

        public final java.util.Map<java.lang.String,​java.lang.String> stats​(java.net.InetSocketAddress address)
                                                                           throws MemcachedException,
                                                                                  java.lang.InterruptedException,
                                                                                  java.util.concurrent.TimeoutException
        Specified by:
        stats in interface MemcachedClient
        Throws:
        MemcachedException
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
      • stats

        public final java.util.Map<java.lang.String,​java.lang.String> stats​(java.net.InetSocketAddress address,
                                                                                  long timeout)
                                                                           throws MemcachedException,
                                                                                  java.lang.InterruptedException,
                                                                                  java.util.concurrent.TimeoutException
        Description copied from interface: MemcachedClient
        �ョ��瑰������emcached server缁��淇℃�
        Specified by:
        stats in interface MemcachedClient
        Parameters:
        address - ����板�
        timeout - ���瓒��
        Returns:
        Throws:
        MemcachedException
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
      • getStats

        public final java.util.Map<java.net.InetSocketAddress,​java.util.Map<java.lang.String,​java.lang.String>> getStats()
                                                                                                                              throws MemcachedException,
                                                                                                                                     java.lang.InterruptedException,
                                                                                                                                     java.util.concurrent.TimeoutException
        Specified by:
        getStats in interface MemcachedClient
        Throws:
        MemcachedException
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
      • getStatsByItem

        public final java.util.Map<java.net.InetSocketAddress,​java.util.Map<java.lang.String,​java.lang.String>> getStatsByItem​(java.lang.String itemName)
                                                                                                                                    throws MemcachedException,
                                                                                                                                           java.lang.InterruptedException,
                                                                                                                                           java.util.concurrent.TimeoutException
        Description copied from interface: MemcachedClient
        Get special item stats. "stats items" for example
        Specified by:
        getStatsByItem in interface MemcachedClient
        Returns:
        Throws:
        MemcachedException
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
      • getStatsByItem

        public final java.util.Map<java.net.InetSocketAddress,​java.util.Map<java.lang.String,​java.lang.String>> getStatsByItem​(java.lang.String itemName,
                                                                                                                                           long timeout)
                                                                                                                                    throws MemcachedException,
                                                                                                                                           java.lang.InterruptedException,
                                                                                                                                           java.util.concurrent.TimeoutException
        Specified by:
        getStatsByItem in interface MemcachedClient
        Throws:
        MemcachedException
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
      • getVersions

        public final java.util.Map<java.net.InetSocketAddress,​java.lang.String> getVersions()
                                                                                           throws java.util.concurrent.TimeoutException,
                                                                                                  java.lang.InterruptedException,
                                                                                                  MemcachedException
        Description copied from interface: MemcachedClient
        Get all connected memcached servers's version.
        Specified by:
        getVersions in interface MemcachedClient
        Returns:
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • getVersions

        public final java.util.Map<java.net.InetSocketAddress,​java.lang.String> getVersions​(long timeout)
                                                                                           throws java.util.concurrent.TimeoutException,
                                                                                                  java.lang.InterruptedException,
                                                                                                  MemcachedException
        Specified by:
        getVersions in interface MemcachedClient
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • getStats

        public java.util.Map<java.net.InetSocketAddress,​java.util.Map<java.lang.String,​java.lang.String>> getStats​(long timeout)
                                                                                                                        throws MemcachedException,
                                                                                                                               java.lang.InterruptedException,
                                                                                                                               java.util.concurrent.TimeoutException
        Description copied from interface: MemcachedClient
        Get stats from all memcached servers
        Specified by:
        getStats in interface MemcachedClient
        Returns:
        server->item->value map
        Throws:
        MemcachedException
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
      • shutdown0

        protected void shutdown0()
        For subclass override.
      • shutdown

        public final void shutdown()
                            throws java.io.IOException
        Specified by:
        shutdown in interface MemcachedClient
        Throws:
        java.io.IOException
      • sendIncrOrDecrCommand

        private long sendIncrOrDecrCommand​(java.lang.String key,
                                           long delta,
                                           long initValue,
                                           CommandType cmdType,
                                           boolean noreply,
                                           long operationTimeout,
                                           int exp)
                                    throws java.lang.InterruptedException,
                                           java.util.concurrent.TimeoutException,
                                           MemcachedException
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
        MemcachedException
      • setConnectionPoolSize

        public void setConnectionPoolSize​(int poolSize)
        Description copied from interface: MemcachedClient
        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.
        Specified by:
        setConnectionPoolSize in interface MemcachedClient
        Parameters:
        poolSize - pool size,default is one,every memcached has only one connection.
      • delete

        public final boolean delete​(java.lang.String key)
                             throws java.util.concurrent.TimeoutException,
                                    java.lang.InterruptedException,
                                    MemcachedException
        Specified by:
        delete in interface MemcachedClient
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • sendStoreCommand

        private final <T> boolean sendStoreCommand​(Command command,
                                                   long timeout)
                                            throws java.lang.InterruptedException,
                                                   java.util.concurrent.TimeoutException,
                                                   MemcachedException
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
        MemcachedException
      • latchWait

        protected void latchWait​(Command cmd,
                                 long timeout,
                                 Session session)
                          throws java.lang.InterruptedException,
                                 java.util.concurrent.TimeoutException
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
      • getContinuousTimeoutCounter

        private java.util.concurrent.atomic.AtomicInteger getContinuousTimeoutCounter​(Session session)
      • getAvailableServers

        public java.util.Collection<java.net.InetSocketAddress> getAvailableServers()
        Description copied from interface: MemcachedClient
        Returns available memcached servers list.
        Specified by:
        getAvailableServers in interface MemcachedClient
        Returns:
        A available server collection
      • getConnectionSizeBySocketAddress

        public final int getConnectionSizeBySocketAddress​(java.net.InetSocketAddress address)
      • setPrimitiveAsString

        public void setPrimitiveAsString​(boolean primitiveAsString)
        Description copied from interface: MemcachedClient
        Store all primitive type as string,defualt is false.
        Specified by:
        setPrimitiveAsString in interface MemcachedClient
      • setSanitizeKeys

        public void setSanitizeKeys​(boolean sanitizeKeys)
        Description copied from interface: MemcachedClient
        Enables/disables sanitizing keys by URLEncoding.
        Specified by:
        setSanitizeKeys in interface MemcachedClient
        Parameters:
        sanitizeKeys - if true, then URLEncode all keys
      • decodeKey

        private java.lang.String decodeKey​(java.lang.String key)
                                    throws MemcachedException,
                                           java.lang.InterruptedException,
                                           java.util.concurrent.TimeoutException
        Throws:
        MemcachedException
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
      • preProcessKey

        private java.lang.String preProcessKey​(java.lang.String key)
                                        throws MemcachedException,
                                               java.lang.InterruptedException
        Throws:
        MemcachedException
        java.lang.InterruptedException
      • invalidateNamespace

        public void invalidateNamespace​(java.lang.String ns,
                                        long opTimeout)
                                 throws MemcachedException,
                                        java.lang.InterruptedException,
                                        java.util.concurrent.TimeoutException
        Description copied from interface: MemcachedClient
        Invalidate all items under the namespace.
        Specified by:
        invalidateNamespace in interface MemcachedClient
        Parameters:
        ns - the namespace
        opTimeout - operation timeout in milliseconds.
        Throws:
        MemcachedException
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
      • invalidateNamespace

        public void invalidateNamespace​(java.lang.String ns)
                                 throws MemcachedException,
                                        java.lang.InterruptedException,
                                        java.util.concurrent.TimeoutException
        Description copied from interface: MemcachedClient
        Invalidate all namespace under the namespace using the default operation timeout.
        Specified by:
        invalidateNamespace in interface MemcachedClient
        Parameters:
        ns - the namespace
        Throws:
        MemcachedException
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
      • getNamespace

        public java.lang.String getNamespace​(java.lang.String ns)
                                      throws java.util.concurrent.TimeoutException,
                                             java.lang.InterruptedException,
                                             MemcachedException
        Returns the real namespace of ns.
        Parameters:
        ns -
        Returns:
        Throws:
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
        MemcachedException
      • getNSKey

        private java.lang.String getNSKey​(java.lang.String ns)
      • getCounter

        public Counter getCounter​(java.lang.String key,
                                  long initialValue)
        Description copied from interface: MemcachedClient
        Get counter for key,and if the key's value is not set,then set it with initial value.
        Specified by:
        getCounter in interface MemcachedClient
        Returns:
      • getCounter

        public Counter getCounter​(java.lang.String key)
        Description copied from interface: MemcachedClient
        Get counter for key,and if the key's value is not set,then set it with 0.
        Specified by:
        getCounter in interface MemcachedClient
        Returns:
      • getKeyIterator

        @Deprecated
        public KeyIterator getKeyIterator​(java.net.InetSocketAddress address)
                                   throws MemcachedException,
                                          java.util.concurrent.TimeoutException,
                                          java.lang.InterruptedException
        Deprecated.
        memcached 1.6.x will remove cachedump stats command,so this method will be removed in the future
        Description copied from interface: MemcachedClient
        Get key iterator for special memcached server.You must known that the iterator is a snapshot for memcached all keys,it is not real-time.The 'stats cachedump" has length limitation,so iterator could not visit all keys if you have many keys.Your application should not be dependent on this feature.
        Specified by:
        getKeyIterator in interface MemcachedClient
        Returns:
        Throws:
        MemcachedException
        java.util.concurrent.TimeoutException
        java.lang.InterruptedException
      • setEnableHealSession

        public void setEnableHealSession​(boolean enableHealSession)
        Description copied from interface: MemcachedClient
        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.
        Specified by:
        setEnableHealSession in interface MemcachedClient
      • setFailureMode

        public void setFailureMode​(boolean failureMode)
        Description copied from interface: MemcachedClient
        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.
        Specified by:
        setFailureMode in interface MemcachedClient
        Parameters:
        failureMode - true is to configure client in failure mode.
      • getReconnectRequestQueue

        public java.util.Queue<ReconnectRequest> getReconnectRequestQueue()
        Description copied from interface: MemcachedClient
        Returns reconnecting task queue,the queue is thread-safe and 'weakly consistent',but maybe you should not modify it at all.
        Specified by:
        getReconnectRequestQueue in interface MemcachedClient
        Returns:
        The reconnecting task queue,if the client has not been started,returns null.