Class MemcachedSessionDataMap
- java.lang.Object
-
- org.eclipse.jetty.util.component.AbstractLifeCycle
-
- org.eclipse.jetty.memcached.session.MemcachedSessionDataMap
-
- All Implemented Interfaces:
SessionDataMap,LifeCycle
@ManagedObject public class MemcachedSessionDataMap extends AbstractLifeCycle implements SessionDataMap
MemcachedSessionDataMap Uses memcached as a cache for SessionData.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMemcachedSessionDataMap.SessionDataTranscoderSessionDataTranscoder We override memcached deserialization to use our classloader-aware ObjectInputStream.-
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
-
Field Summary
Fields Modifier and Type Field Description protected net.rubyeye.xmemcached.XMemcachedClientBuilder_builderprotected net.rubyeye.xmemcached.MemcachedClient_clientprotected int_expirySecprotected boolean_heartbeatsstatic java.lang.StringDEFAULT_HOSTstatic java.lang.StringDEFAULT_PORT
-
Constructor Summary
Constructors Constructor Description MemcachedSessionDataMap(java.lang.String host, java.lang.String port)MemcachedSessionDataMap(java.util.List<java.net.InetSocketAddress> addresses)MemcachedSessionDataMap(java.util.List<java.net.InetSocketAddress> addresses, int[] weights)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleandelete(java.lang.String id)Delete session dataprotected voiddoStop()net.rubyeye.xmemcached.XMemcachedClientBuildergetBuilder()intgetExpirySec()Expiry time for memached entries.voidinitialize(SessionContext context)Initialize this data map for the given context.booleanisHeartbeats()SessionDataload(java.lang.String id)Read in session data.voidsetExpirySec(int sec)voidsetHeartbeats(boolean heartbeats)voidstore(java.lang.String id, SessionData data)Store the session data.-
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, doStart, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, setStopTimeout, start, stop, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
-
-
-
-
Field Detail
-
DEFAULT_HOST
public static final java.lang.String DEFAULT_HOST
- See Also:
- Constant Field Values
-
DEFAULT_PORT
public static final java.lang.String DEFAULT_PORT
- See Also:
- Constant Field Values
-
_client
protected net.rubyeye.xmemcached.MemcachedClient _client
-
_expirySec
protected int _expirySec
-
_heartbeats
protected boolean _heartbeats
-
_builder
protected net.rubyeye.xmemcached.XMemcachedClientBuilder _builder
-
-
Constructor Detail
-
MemcachedSessionDataMap
public MemcachedSessionDataMap(java.lang.String host, java.lang.String port)- Parameters:
host- address of memcache serverport- address of memcache server
-
MemcachedSessionDataMap
public MemcachedSessionDataMap(java.util.List<java.net.InetSocketAddress> addresses)
-
MemcachedSessionDataMap
public MemcachedSessionDataMap(java.util.List<java.net.InetSocketAddress> addresses, int[] weights)
-
-
Method Detail
-
getBuilder
public net.rubyeye.xmemcached.XMemcachedClientBuilder getBuilder()
- Returns:
- the builder
-
setExpirySec
public void setExpirySec(int sec)
- Parameters:
sec- the expiry to use in seconds
-
getExpirySec
@ManagedAttribute(value="memcached expiry time in sec", readonly=true) public int getExpirySec()
Expiry time for memached entries.- Returns:
- memcached expiry time in sec
-
isHeartbeats
@ManagedAttribute(value="enable memcached heartbeats", readonly=true) public boolean isHeartbeats()
-
setHeartbeats
public void setHeartbeats(boolean heartbeats)
-
initialize
public void initialize(SessionContext context)
Description copied from interface:SessionDataMapInitialize this data map for the given context. A SessionDataMap can only be used by one context(/session manager).- Specified by:
initializein interfaceSessionDataMap- Parameters:
context- context associated
-
load
public SessionData load(java.lang.String id) throws java.lang.Exception
Description copied from interface:SessionDataMapRead in session data.- Specified by:
loadin interfaceSessionDataMap- Parameters:
id- identity of session to load- Returns:
- the SessionData matching the id
- Throws:
java.lang.Exception- if unable to load session data
-
store
public void store(java.lang.String id, SessionData data) throws java.lang.ExceptionDescription copied from interface:SessionDataMapStore the session data.- Specified by:
storein interfaceSessionDataMap- Parameters:
id- identity of session to storedata- info of session to store- Throws:
java.lang.Exception- if unable to write session data
-
delete
public boolean delete(java.lang.String id) throws java.lang.ExceptionDescription copied from interface:SessionDataMapDelete session data- Specified by:
deletein interfaceSessionDataMap- Parameters:
id- identity of session to delete- Returns:
- true if the session was deleted
- Throws:
java.lang.Exception- if unable to delete session data
-
doStop
protected void doStop() throws java.lang.Exception- Overrides:
doStopin classAbstractLifeCycle- Throws:
java.lang.Exception
-
-