[
https://issues.apache.org/jira/browse/SHIRO-317?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13596567#comment-13596567
]
Benjamin Marwell edited comment on SHIRO-317 at 2/1/21, 10:32 AM:
------------------------------------------------------------------
No Problem, but I did forget a simple thing
{code}
@Override
public Serializable get(Serializable o) throws CacheException {
Serializable session = sessionThreadLocal.get();
if (session != null) {
return session;
} else {
session = wrappedCache.get(o);
sessionThreadLocal.set(session);
return session;
}
}
{code}
If you have to go to the real cache, it helps to put what comes back into
ThreadLocal. ;)
Mark
was (Author: bytor99999):
No Problem, but I did forget a simple thing
@Override
public Serializable get(Serializable o) throws CacheException {
Serializable session = sessionThreadLocal.get();
if (session != null) {
return session;
} else {
session = wrappedCache.get(o);
sessionThreadLocal.set(session);
return session;
}
}
If you have to go to the real cache, it helps to put what comes back into
ThreadLocal. ;)
Mark
> Read session from cache once per request
> ----------------------------------------
>
> Key: SHIRO-317
> URL: https://issues.apache.org/jira/browse/SHIRO-317
> Project: Shiro
> Issue Type: New Feature
> Affects Versions: 1.1.0, 1.2.0, 1.2.1
> Reporter: Luke Biddell
> Assignee: Les Hazlewood
> Priority: Minor
>
> As per our discussion on the mailing thread, I've wired up my sessions to be
> stored in memcached (membase in the longer term). On a per request basis I'm
> seeing approximately 5 hits on my cache to retrieve the session. I would
> expect to see only one hit per threaded request, with the session stored as a
> thread local.
> For distributed caches this saves on network calls and for local caches it
> will save on potential lock contention.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)