First
Directly configure tomcat session management so that the session can be directly managed by redis.
The main configuration is in
Modify tomcat context. xml
<Valve className = "com. radiadesign. catalina. session. RedisSessionHandlerValve"/>
<Manager className = "com. radiadesign. catalina. session. RedisSessionManager"
Host = "localhost" port = "6379" database = "0" maxInactiveInterval = "120"/>
Type 2: shiro
I will share the ideas to be verified.
<! -- Session Manager -->
<Bean id = "sessionManager" class = "org. apache. shiro. web. session. mgt. DefaultWebSessionManager">
<! -- Session expiration time, in milliseconds -->
<Property name = "globalSessionTimeout" value = "600000" type = "regxph" text = "yourobjectname"/>
<! -- Delete invalid session -->
<Property name = "deleteInvalidSessions" value = "true"/>
<Property name = "sessionDAO" ref = "redisSessionDAO"/>
</Bean>
<! -- RedisSessionDAO -->
<Bean id = "redisSessionDAO" class = "org. crazycake. shiro. RedisSessionDAO">
<Property name = "redisManager" ref = "redisManager"/> </bean>
<! -- Shiro redisManager -->
<Bean id = "redisManager" class = "org. crazycake. shiro. RedisManager">
<Property name = "host" value = "$ {redis. host}"/>
<Property name = "port" value = "$ {redis. port}"/>
</Bean>