Class KetamaMemcachedSessionLocator

    • Field Detail

      • ketamaSessions

        private transient volatile java.util.TreeMap<java.lang.Long,​java.util.List<Session>> ketamaSessions
      • maxTries

        private int maxTries
      • DEFAULT_PORT

        static final int DEFAULT_PORT
        compatible with nginx-upstream-consistent,patched by wolfg1969
        See Also:
        Constant Field Values
      • cwNginxUpstreamConsistent

        private final boolean cwNginxUpstreamConsistent
      • gwhalinMemcachedJavaClientCompatibiltyConsistent

        private final boolean gwhalinMemcachedJavaClientCompatibiltyConsistent
    • Constructor Detail

      • KetamaMemcachedSessionLocator

        public KetamaMemcachedSessionLocator()
        Create a KetamaMemcachedSessionLocator with default config.
      • KetamaMemcachedSessionLocator

        public KetamaMemcachedSessionLocator​(boolean cwNginxUpstreamConsistent)
        Create a KetamaMemcachedSessionLocator
        Parameters:
        cwNginxUpstreamConsistent - true if compatible with nginx up stream memcached consistent algorithm.
      • KetamaMemcachedSessionLocator

        public KetamaMemcachedSessionLocator​(HashAlgorithm alg)
        Create a KetamaMemcachedSessionLocator with a special hash algorithm.
        Parameters:
        alg -
      • KetamaMemcachedSessionLocator

        public KetamaMemcachedSessionLocator​(HashAlgorithm alg,
                                             boolean cwNginxUpstreamConsistent)
      • KetamaMemcachedSessionLocator

        public KetamaMemcachedSessionLocator​(HashAlgorithm alg,
                                             boolean cwNginxUpstreamConsistent,
                                             boolean gwhalinMemcachedJavaClientCompatibiltyConsistent)
      • KetamaMemcachedSessionLocator

        public KetamaMemcachedSessionLocator​(java.util.List<Session> list,
                                             HashAlgorithm alg)
    • Method Detail

      • buildMap

        private final void buildMap​(java.util.Collection<Session> list,
                                    HashAlgorithm alg)
      • getSockStr

        private java.lang.String getSockStr​(Session session)
      • getSessionList

        private java.util.List<Session> getSessionList​(java.util.TreeMap<java.lang.Long,​java.util.List<Session>> sessionMap,
                                                       long k)
      • getSessionByKey

        public final Session getSessionByKey​(java.lang.String key)
        Description copied from interface: MemcachedSessionLocator
        Returns a session by special key.
        Returns:
      • getSessionByHash

        public final Session getSessionByHash​(long hash)
      • nextHash

        public final long nextHash​(long hashVal,
                                   java.lang.String key,
                                   int tries)
      • updateSessions

        public final void updateSessions​(java.util.Collection<Session> list)
        Description copied from interface: MemcachedSessionLocator
        Update sessions when session was added or removed.
        Parameters:
        list - The newer sessions