This commit is contained in:
Jan Bartel 2016-11-05 13:09:16 +11:00
parent fcab745e77
commit ef06948790
1 changed files with 25 additions and 8 deletions

View File

@ -22,6 +22,9 @@ package org.eclipse.jetty.server.session;
import java.util.Set;
import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
/**
* CachingSessionDataStore
@ -44,7 +47,7 @@ import org.eclipse.jetty.util.component.ContainerLifeCycle;
*/
public class CachingSessionDataStore extends ContainerLifeCycle implements SessionDataStore
{
private final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session");
/**
* The actual store for the session data
*/
@ -98,8 +101,15 @@ public class CachingSessionDataStore extends ContainerLifeCycle implements Sessi
SessionData d = null;
try
{
//check to see if the session data is already in the cache
d = _cache.load(id);
}
catch (Exception e)
{
LOG.warn(e);
}
if (d != null)
return d; //cache hit
@ -177,11 +187,18 @@ public class CachingSessionDataStore extends ContainerLifeCycle implements Sessi
*/
@Override
public boolean exists(String id) throws Exception
{
try
{
//check the cache first
SessionData data = _cache.load(id);
if (data != null)
return true;
}
catch (Exception e)
{
LOG.warn(e);
}
//then the delegate store
return _store.exists(id);