NutzCN Logo
问答 用户非正常退出比如关闭浏览器且超过session超时后,session缓存不会被清理
发布于 2638天前 作者 yueming158 4761 次浏览 复制 上一个帖子 下一个帖子
标签:

请教:用户非正常退出比如关闭浏览器且超过session超时后,session缓存不会被清理。

6 回复

用shiro做session持久化了?

用的ehcahce和redis做的缓存

shiro.ini 贴一下看看

[main]

#Session管理器,关闭定时校验机制,持久化环境下会非常耗内存
sessionManager = org.apache.shiro.web.session.mgt.DefaultWebSessionManager
sessionManager.sessionValidationSchedulerEnabled = false

#带缓存的SessionDAO
sessionDAO = org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO
sessionManager.sessionDAO = $sessionDAO
securityManager.sessionManager = $sessionManager

sessionIdGenerator = org.nutz.integration.shiro.UU32SessionIdGenerator
securityManager.sessionManager.sessionDAO.sessionIdGenerator = $sessionIdGenerator

# 2层缓存配置
jedisAgent = org.nutz.integration.jedis.JedisAgent
cacheManager_ehcache = org.apache.shiro.cache.ehcache.EhCacheManager
cacheManager_ehcache.cacheManagerConfigFile=classpath:ehcache.xml
cacheManager_redis = org.nutz.plugins.cache.impl.redis.RedisCacheManager
cacheManager_redis.mode=kv
cacheManager_redis.debug=true
cacheManager = org.nutz.plugins.cache.impl.lcache.LCacheManager
cacheManager.level1 = $cacheManager_ehcache
cacheManager.level2 = $cacheManager_redis
cacheManager.jedisAgent = $jedisAgent
securityManager.cacheManager = $cacheManager

sessionIdCookie=org.apache.shiro.web.servlet.SimpleCookie
sessionIdCookie.name=sid
sessionIdCookie.maxAge=1800000
sessionIdCookie.httpOnly=true
sessionManager.sessionIdCookie=$sessionIdCookie
sessionManager.sessionIdCookieEnabled=true
sessionManager.globalSessionTimeout=1800000

# realm声明
nutzdao_realm = com.kaisa.kams.components.security.SimpleAuthorizingRealm
authc = org.nutz.integration.shiro.SimpleAuthenticationFilter


authc.loginUrl  = /user/toLogin
logout.redirectUrl= /user/toLogin

roles.unauthorizedUrl=/authority/unauthorized
perms.unauthorizedUrl=/authority/unauthorized


[urls]
/user/logout = logout
/user/error  = anon
/user/login  = anon

把这一行注释掉, 或者改成true, 默认是true.

sessionManager.sessionValidationSchedulerEnabled = false

好的,谢谢!

添加回复
请先登陆
回到顶部