@Retention(value=RUNTIME) @Target(value=TYPE) @Documented @Import(value=RedisHttpSessionConfiguration.class) @Configuration(proxyBeanMethods=false) public @interface EnableRedisHttpSession
@Configuration class to expose the
SessionRepositoryFilter as a bean named springSessionRepositoryFilter
and backed by Redis. In order to leverage the annotation, a single
RedisConnectionFactory must be provided. For example:
@Configuration
@EnableRedisHttpSession
public class RedisHttpSessionConfig {
@Bean
public LettuceConnectionFactory redisConnectionFactory() {
return new LettuceConnectionFactory();
}
}
More advanced configurations can extend RedisHttpSessionConfiguration instead.EnableSpringHttpSession| Modifier and Type | Optional Element and Description |
|---|---|
java.lang.String |
cleanupCron
The cron expression for expired session cleanup job.
|
org.springframework.session.FlushMode |
flushMode
Flush mode for the Redis sessions.
|
int |
maxInactiveIntervalInSeconds
The session timeout in seconds.
|
RedisFlushMode |
redisFlushMode
Deprecated.
since 2.2.0 in favor of
flushMode() |
java.lang.String |
redisNamespace
Defines a unique namespace for keys.
|
org.springframework.session.SaveMode |
saveMode
Save mode for the session.
|
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.
@Deprecated public abstract RedisFlushMode redisFlushMode
flushMode()ON_SAVE which only
updates the backing Redis when SessionRepository.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 usepublic abstract org.springframework.session.FlushMode flushMode
ON_SAVE which only
updates the backing Redis when SessionRepository.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.
FlushMode to use