shiro-redisson
功能简介
1.使用redisson包解决redis缓存
2.解决shiro-redis使用*查询时,导致redis长时间卡死
3.解决使用spring-boot-devtools,出现ClassCastException异常
4.支持redisson提供的编码类型,https://github.com/redisson/redisson/wiki/4.-data-serialization
JDK
1.8/11/12/13
java使用
@Bean
public MyShiroRealm myShiroRealm() {
return new MyShiroRealm();
}
@Bean
public SessionManager sessionManager(SessionDAO redisSessionDAO, ObjectProvider<SessionListener> sessionListenersProvider) {
List<SessionListener> sessionListeners = sessionListenersProvider.stream().collect(Collectors.toList());
DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
sessionManager.setSessionDAO(redisSessionDAO);
sessionManager.setSessionListeners(sessionListeners);
return mySessionManager;
}
/**
* 内置session监听器,保证删除session/cache冗余的数据信息
*/
@Bean
public SessionListener sessionListener(SessionDAO redisSessionDAO, MyShiroRealm myShiroRealm) {
return new RedisSessionListener(redisSessionDAO, myShiroRealm);
}
@Bean
public RedisCacheManager cacheManager(RedissonClient redissonClient) {
return new RedisCacheManager(redissonClient);
}
@Bean
public RedisSessionDAO redisSessionDAO(RedisCacheManager cacheManager) {
return new RedisSessionDAO(cacheManager);
}