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 class
MemcachedSessionDataMap.SessionDataTranscoder
SessionDataTranscoder 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
_builder
protected net.rubyeye.xmemcached.MemcachedClient
_client
protected int
_expirySec
protected boolean
_heartbeats
static java.lang.String
DEFAULT_HOST
static java.lang.String
DEFAULT_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 boolean
delete(java.lang.String id)
Delete session dataprotected void
doStop()
net.rubyeye.xmemcached.XMemcachedClientBuilder
getBuilder()
int
getExpirySec()
Expiry time for memached entries.void
initialize(SessionContext context)
Initialize this data map for the given context.boolean
isHeartbeats()
SessionData
load(java.lang.String id)
Read in session data.void
setExpirySec(int sec)
void
setHeartbeats(boolean heartbeats)
void
store(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:SessionDataMap
Initialize this data map for the given context. A SessionDataMap can only be used by one context(/session manager).- Specified by:
initialize
in interfaceSessionDataMap
- Parameters:
context
- context associated
-
load
public SessionData load(java.lang.String id) throws java.lang.Exception
Description copied from interface:SessionDataMap
Read in session data.- Specified by:
load
in 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.Exception
Description copied from interface:SessionDataMap
Store the session data.- Specified by:
store
in 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.Exception
Description copied from interface:SessionDataMap
Delete session data- Specified by:
delete
in 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:
doStop
in classAbstractLifeCycle
- Throws:
java.lang.Exception
-
-