@Retention(value=RUNTIME) @Target(value=TYPE) @Documented @Import(value=RedisWebSessionConfiguration.class) @Configuration public @interface EnableRedisWebSession
@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
@EnableRedisWebSession
public class RedisWebSessionConfig {
@Bean
public LettuceConnectionFactory redisConnectionFactory() {
return new LettuceConnectionFactory();
}
}
More advanced configurations can extend RedisWebSessionConfiguration instead.EnableSpringWebSession| Modifier and Type | Optional Element and Description |
|---|---|
int |
maxInactiveIntervalInSeconds
The session timeout in seconds.
|
RedisFlushMode |
redisFlushMode
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
spring:session: to
<redisNamespace>:.
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
ON_SAVE which only
updates the backing Redis when ReactiveSessionRepository.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