Package net.rubyeye.xmemcached.impl
Class KetamaMemcachedSessionLocator
- java.lang.Object
-
- net.rubyeye.xmemcached.impl.AbstractMemcachedSessionLocator
-
- net.rubyeye.xmemcached.impl.KetamaMemcachedSessionLocator
-
- All Implemented Interfaces:
MemcachedSessionLocator
public class KetamaMemcachedSessionLocator extends AbstractMemcachedSessionLocator
Consistent Hash Algorithm implementation,based on TreeMap.tailMap(hash) method.- Author:
- dennis
-
-
Field Summary
-
Fields inherited from class net.rubyeye.xmemcached.impl.AbstractMemcachedSessionLocator
failureMode
-
-
Constructor Summary
Constructors Constructor Description KetamaMemcachedSessionLocator()Create a KetamaMemcachedSessionLocator with default config.KetamaMemcachedSessionLocator(boolean cwNginxUpstreamConsistent)Create a KetamaMemcachedSessionLocatorKetamaMemcachedSessionLocator(List<Session> list, HashAlgorithm alg)KetamaMemcachedSessionLocator(HashAlgorithm alg)Create a KetamaMemcachedSessionLocator with a special hash algorithm.KetamaMemcachedSessionLocator(HashAlgorithm alg, boolean cwNginxUpstreamConsistent)KetamaMemcachedSessionLocator(HashAlgorithm alg, boolean cwNginxUpstreamConsistent, boolean gwhalinMemcachedJavaClientCompatibiltyConsistent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SessiongetSessionByHash(long hash)SessiongetSessionByKey(String key)Returns a session by special key.longnextHash(long hashVal, String key, int tries)voidupdateSessions(Collection<Session> list)Update sessions when session was added or removed.-
Methods inherited from class net.rubyeye.xmemcached.impl.AbstractMemcachedSessionLocator
setFailureMode
-
-
-
-
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(List<Session> list, HashAlgorithm alg)
-
-
Method Detail
-
getSessionByKey
public final Session getSessionByKey(String key)
Description copied from interface:MemcachedSessionLocatorReturns a session by special key.- Returns:
-
getSessionByHash
public final Session getSessionByHash(long hash)
-
nextHash
public final long nextHash(long hashVal, String key, int tries)
-
updateSessions
public final void updateSessions(Collection<Session> list)
Description copied from interface:MemcachedSessionLocatorUpdate sessions when session was added or removed.- Parameters:
list- The newer sessions
-
-