Package net.rubyeye.xmemcached.impl
Class ArrayMemcachedSessionLocator
- java.lang.Object
-
- net.rubyeye.xmemcached.impl.AbstractMemcachedSessionLocator
-
- net.rubyeye.xmemcached.impl.ArrayMemcachedSessionLocator
-
- All Implemented Interfaces:
MemcachedSessionLocator
public class ArrayMemcachedSessionLocator extends AbstractMemcachedSessionLocator
Session locator base on hash(key) mod sessions.size().Standard hash strategy
-
-
Field Summary
Fields Modifier and Type Field Description private HashAlgorithm
hashAlgorighm
(package private) java.util.Random
rand
private java.util.List<java.util.List<Session>>
sessions
-
Fields inherited from class net.rubyeye.xmemcached.impl.AbstractMemcachedSessionLocator
failureMode
-
-
Constructor Summary
Constructors Constructor Description ArrayMemcachedSessionLocator()
ArrayMemcachedSessionLocator(HashAlgorithm hashAlgorighm)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getHash(int size, java.lang.String key)
long
getNext(int size, long start)
private Session
getRandomSession(java.util.List<Session> sessions)
Session
getSessionByKey(java.lang.String key)
Returns a session by special key.void
setHashAlgorighm(HashAlgorithm hashAlgorighm)
void
updateSessions(java.util.Collection<Session> list)
Update sessions when session was added or removed.-
Methods inherited from class net.rubyeye.xmemcached.impl.AbstractMemcachedSessionLocator
setFailureMode
-
-
-
-
Field Detail
-
hashAlgorighm
private HashAlgorithm hashAlgorighm
-
sessions
private transient volatile java.util.List<java.util.List<Session>> sessions
-
rand
final java.util.Random rand
-
-
Constructor Detail
-
ArrayMemcachedSessionLocator
public ArrayMemcachedSessionLocator()
-
ArrayMemcachedSessionLocator
public ArrayMemcachedSessionLocator(HashAlgorithm hashAlgorighm)
-
-
Method Detail
-
setHashAlgorighm
public final void setHashAlgorighm(HashAlgorithm hashAlgorighm)
-
getHash
public final long getHash(int size, java.lang.String key)
-
getSessionByKey
public final Session getSessionByKey(java.lang.String key)
Description copied from interface:MemcachedSessionLocator
Returns a session by special key.- Returns:
-
getNext
public final long getNext(int size, long start)
-
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
-
-