@Retention(value=RUNTIME) @Target(value=TYPE) @Documented @Import(value=RedisHttpSessionConfiguration.class) @Configuration 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 JedisConnectionFactory connectionFactory() throws Exception {
return new JedisConnectionFactory();
}
}
More advanced configurations can extend RedisHttpSessionConfiguration
instead.EnableSpringHttpSession
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
SessionRepository.save(org.springframework.session.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