@Retention(value=RUNTIME) @Target(value=TYPE) @Documented @Import(value=RedisReactorSessionConfiguration.class) @Configuration public @interface EnableRedisReactorSession
@Configuration class to expose the
WebSessionManager as a bean named
webSessionManager and backed by Reactive Redis. In order to leverage the
annotation, a single ReactiveRedisConnectionFactory must be provided. For
example:
@Configuration
@EnableRedisReactorSession
public class RedisReactorSessionConfig {
@Bean
public LettuceConnectionFactory redisConnectionFactory() {
return new LettuceConnectionFactory();
}
}
More advanced configurations can extend RedisReactorSessionConfiguration
instead.EnableSpringWebSession| Modifier and Type | Optional Element and Description |
|---|---|
int |
maxInactiveIntervalInSeconds |
RedisFlushMode |
redisFlushMode
Sets the flush mode for the Redis sessions.
|
java.lang.String |
redisNamespace
Defines a unique namespace for keys.
|
public abstract int maxInactiveIntervalInSeconds
public abstract java.lang.String redisNamespace
Defines a unique namespace for keys. The value is used to isolate sessions by
changing the prefix from spring:session: to
spring:session:<redisNamespace>:. The default is "" such that all Redis
keys begin with spring:session:.
For example, if you had an application named "Application A" that needed to keep the sessions isolated from "Application B" you could set two different values for the applications and they could function within the same Redis instance.
public abstract RedisFlushMode redisFlushMode
Sets the flush mode for the Redis sessions. The default is ON_SAVE which only
updates the backing Redis when ReactorSessionRepository.save(Session) is
invoked. In a web environment this happens just before the HTTP response is
committed.
Setting the value to IMMEDIATE will ensure that the any updates to the Session are immediately written to the Redis instance.
RedisFlushMode to use