Class KetamaMemcachedSessionLocator
java.lang.Object
net.rubyeye.xmemcached.impl.AbstractMemcachedSessionLocator
net.rubyeye.xmemcached.impl.KetamaMemcachedSessionLocator
- All Implemented Interfaces:
MemcachedSessionLocator
Consistent Hash Algorithm implementation,based on TreeMap.tailMap(hash) method.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean(package private) static final intcompatible with nginx-upstream-consistent,patched by wolfg1969private final booleanprivate final HashAlgorithmprivate int(package private) static final intFields inherited from class AbstractMemcachedSessionLocator
failureMode -
Constructor Summary
ConstructorsConstructorDescriptionCreate a KetamaMemcachedSessionLocator with default config.KetamaMemcachedSessionLocator(boolean cwNginxUpstreamConsistent) Create a KetamaMemcachedSessionLocatorKetamaMemcachedSessionLocator(List<Session> list, HashAlgorithm alg) Create a KetamaMemcachedSessionLocator with a special hash algorithm.KetamaMemcachedSessionLocator(HashAlgorithm alg, boolean cwNginxUpstreamConsistent) KetamaMemcachedSessionLocator(HashAlgorithm alg, boolean cwNginxUpstreamConsistent, boolean gwhalinMemcachedJavaClientCompatibiltyConsistent) -
Method Summary
Modifier and TypeMethodDescriptionprivate final voidbuildMap(Collection<Session> list, HashAlgorithm alg) final SessiongetSessionByHash(long hash) final SessiongetSessionByKey(String key) Returns a session by special key.getSessionList(TreeMap<Long, List<Session>> sessionMap, long k) private StringgetSockStr(Session session) final longfinal voidupdateSessions(Collection<Session> list) Update sessions when session was added or removed.Methods inherited from class AbstractMemcachedSessionLocator
setFailureMode
-
Field Details
-
NUM_REPS
static final int NUM_REPS- See Also:
-
ketamaSessions
-
hashAlg
-
maxTries
private int maxTries -
DEFAULT_PORT
static final int DEFAULT_PORTcompatible with nginx-upstream-consistent,patched by wolfg1969- See Also:
-
cwNginxUpstreamConsistent
private final boolean cwNginxUpstreamConsistent -
gwhalinMemcachedJavaClientCompatibiltyConsistent
private final boolean gwhalinMemcachedJavaClientCompatibiltyConsistent
-
-
Constructor Details
-
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
Create a KetamaMemcachedSessionLocator with a special hash algorithm.- Parameters:
alg-
-
KetamaMemcachedSessionLocator
-
KetamaMemcachedSessionLocator
public KetamaMemcachedSessionLocator(HashAlgorithm alg, boolean cwNginxUpstreamConsistent, boolean gwhalinMemcachedJavaClientCompatibiltyConsistent) -
KetamaMemcachedSessionLocator
-
-
Method Details
-
buildMap
-
getSockStr
-
getSessionList
-
getSessionByKey
Description copied from interface:MemcachedSessionLocatorReturns a session by special key.- Parameters:
key-- Returns:
-
getSessionByHash
-
nextHash
-
updateSessions
Description copied from interface:MemcachedSessionLocatorUpdate sessions when session was added or removed.- Parameters:
list- The newer sessions
-