<dependency>
<groupId>org.crazycake</groupId>
<artifactId>shiro-redis</artifactId>
<version>3.2.3</version>
</dependency>
/**
* redis 缓冲策略对应 RedisCacheConfiguration
*/
private RedisCacheManager redisCacheManager(){
RedisCacheManager redisCacheManager = new RedisCacheManager();
redisCacheManager.setRedisManager(redisManager());
//600s
redisCacheManager.setExpire(600);
return redisCacheManager;
}
/**
* redis管理器, 只会存用户储权限认证的sql (即doGetAuthorizationInfo()方法调用的sql)
*/
private RedisManager redisManager(){
return new RedisManager();
}
修改
@Bean
public DefaultWebSecurityManager securityManager(Realm userRealm) {
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
//关联realm
securityManager.setRealm(userRealm);
//设置cookie管理器
securityManager.setRememberMeManager(cookieRememberMeManager());
//shiro关联redis
securityManager.setCacheManager(redisCacheManager());
return securityManager;
}