@EnableRedisHttpSession
关注下这个注解,支持配置以下属性:
maxInactiveIntervalInSeconds:最大不活跃时间间隔,默认1800s。即超过这个时间间隔,session将会失效。
redisNamespace:redis命名空间,默认为空。多中心集成的时候,通过命名空间区分是否使用同一个session。
比如我这里设置的redisNamespace=iotcmp-cc,那么redis命名空间前缀即spring:session:iotcmp-cc
redisFlushMode:redis flush模式,支持两种模式:ON_SAVE和IMMEDIATE,默认ON_SAVE。
关于这两种模式的描述:
public enum RedisFlushMode {
/**
* Only writes to Redis when
* {@link SessionRepository#save(org.springframework.session.Session)} is invoked. In
* a web environment this is typically done as soon as the HTTP response is committed.
*/
ON_SAVE,
/**
* Writes to Redis as soon as possible. For example
* {@link SessionRepository#createSession()} will write the session to Redis. Another
* example is that setting an attribute on the session will also write to Redis
* immediately.
*/
IMMEDIATE
}