Do sessionDAO and cacheManager in shiro need to be set up at the same time?

recently, we integrated shiro with springboot and used redis as the session cache container for shiro. Most netizens on Baidu shiro configured the same cacheManager and sessionDAO, in SecurityManager and checked the source code with questions. We found that the storage of shiro"s session only needs to inherit the AbstractSessionDAO implementation, the abstract method in which redis is used to save session, so it is doubtful why we still need to implement CacheManager interface, and then SecurityManager configure a cacheManager, which is not superfluous. It"s not useful at all. I don"t know if I understand it correctly. Please let me know clearly. Thank you here!

clipboard.png

Mar.06,2021

CacheManager is CacheManager
SessionDAO is SessionDAO
their responsibilities are different

SessionDAO can implement cached or non-cached

for your question
just want to save Session in Redis, to naturally implement the SessionDAO of Redis
and CacheManager is not only used for CachingSessionDAO, but also CachingRealm

Menu