#常见的会话解决方案
- 粘性方案 sticky session
- 会话复制 session replication
- 集中会话 centralized session
Spring 为我们定制了一个HttpSession
- SessionRepositoryRequestWrapper
- SessionRepositoryFilter
- DelegatingFilterProxy
引入 spring-session-data-redis 依赖
- @EnableRedisHttpSession
- 提供 RedisConnectionFactory
- AbstractHTTPSessionApplicationInitializer
- 配置DelegatingFilterProxy
properties文件配置熟悉
1
2
3
4
5 spring.redis.host=localhost
spring.session.store-type= redis
spring.session.timeout = 600
spring.session.flush-mode= on-save
spring.session.redis.namespace= spring:redis