public interface SessionCache extends LifeCycle
Session
objects for a context.
Ideally, multiple requests for the same session id in the same context will always
share the same Session object from the SessionCache, but it would be possible
for implementations of SessionCache to create a fresh object for each request.
The SessionData pertaining to the Session objects is obtained from/written to a SessionDataStore.
The SessionDataStore is the authoritative source of session data:
LifeCycle.Listener
Modifier and Type | Field and Description |
---|---|
static int |
EVICT_ON_INACTIVITY |
static int |
EVICT_ON_SESSION_EXIT |
static int |
NEVER_EVICT |
Modifier and Type | Method and Description |
---|---|
Set<String> |
checkExpiration(Set<String> candidates)
Check a list of session ids that belong to potentially expired
sessions.
|
void |
checkInactiveSession(Session session)
Check a Session to see if it might be appropriate to
evict or expire.
|
boolean |
contains(String id)
Check to see if a Session is in the cache.
|
Session |
delete(String id)
Remove a Session completely: from both this
cache and the SessionDataStore.
|
boolean |
exists(String id)
Check to see if a session exists: WILL consult the
SessionDataStore.
|
Session |
get(String id)
Get an existing Session.
|
int |
getEvictionPolicy() |
SessionDataStore |
getSessionDataStore() |
SessionHandler |
getSessionHandler() |
void |
initialize(SessionContext context) |
boolean |
isRemoveUnloadableSessions() |
boolean |
isSaveOnCreate() |
boolean |
isSaveOnInactiveEviction() |
Session |
newSession(HttpServletRequest request,
String id,
long time,
long maxInactiveMs)
Create an entirely new Session.
|
Session |
newSession(SessionData data)
Re-materialize a Session that has previously existed.
|
void |
put(String id,
Session session)
Finish using a Session.
|
Session |
renewSessionId(String oldId,
String newId)
Change the id of a Session.
|
void |
setEvictionPolicy(int policy)
Sessions in this cache can be:
never evicted
evicted once the last request exits
evicted after a configurable period of inactivity
|
void |
setRemoveUnloadableSessions(boolean removeUnloadableSessions)
If the data for a session exists but is unreadable,
the SessionCache can instruct the SessionDataStore to delete it.
|
void |
setSaveOnCreate(boolean saveOnCreate)
Whether or not a session that is newly created should be
immediately saved.
|
void |
setSaveOnInactiveEviction(boolean saveOnEvict)
Whether or not a a session that is about to be evicted should
be saved before being evicted.
|
void |
setSessionDataStore(SessionDataStore sds)
A SessionDataStore that is the authoritative source
of session information.
|
void |
shutdown() |
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
static final int NEVER_EVICT
static final int EVICT_ON_SESSION_EXIT
static final int EVICT_ON_INACTIVITY
void initialize(SessionContext context)
context
- void shutdown()
SessionHandler getSessionHandler()
Session newSession(HttpServletRequest request, String id, long time, long maxInactiveMs)
request
- id
- time
- maxInactiveMs
- Session newSession(SessionData data)
data
- Session renewSessionId(String oldId, String newId) throws Exception
oldId
- newId
- Exception
Session get(String id) throws Exception
id
- Exception
void put(String id, Session session) throws Exception
id
- session
- Exception
boolean contains(String id) throws Exception
id
- Exception
boolean exists(String id) throws Exception
id
- Exception
Session delete(String id) throws Exception
id
- Exception
Set<String> checkExpiration(Set<String> candidates)
candidates
- the session ids to checkvoid checkInactiveSession(Session session)
session
- void setSessionDataStore(SessionDataStore sds)
sds
- SessionDataStore getSessionDataStore()
void setEvictionPolicy(int policy)
policy
- -1 is never evict; 0 is evict-on-exit; and any other positive
value is the time in seconds that a session can be idle before it can
be evicted.int getEvictionPolicy()
void setSaveOnInactiveEviction(boolean saveOnEvict)
saveOnEvict
- boolean isSaveOnInactiveEviction()
void setSaveOnCreate(boolean saveOnCreate)
saveOnCreate
- boolean isSaveOnCreate()
void setRemoveUnloadableSessions(boolean removeUnloadableSessions)
removeUnloadableSessions
- boolean isRemoveUnloadableSessions()
Copyright © 1995–2017 Webtide. All rights reserved.