Annotation Interface EnableRedisWebSession


@Retention(RUNTIME) @Target(TYPE) @Documented @Import(RedisWebSessionConfiguration.class) @Configuration(proxyBeanMethods=false) public @interface EnableRedisWebSession
Add this annotation to an @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.
Since:
2.0.0
See Also:
  • Element Details

    • maxInactiveIntervalInSeconds

      int maxInactiveIntervalInSeconds
      The session timeout in seconds. By default, it is set to 1800 seconds (30 minutes). A negative number means permanently valid.
      Returns:
      the seconds a session can be inactive before expiring
      Default:
      1800
    • redisNamespace

      String redisNamespace
      Defines a unique namespace for keys. The value is used to isolate sessions by changing the prefix from default 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.

      Returns:
      the unique namespace for keys
      Default:
      "spring:session"
    • redisFlushMode

      @Deprecated RedisFlushMode redisFlushMode
      Deprecated.
      since 2.2.0 as support IMMEDIATE is removed
      Flush mode for the Redis sessions. The default is 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.

      Returns:
      the RedisFlushMode to use
      Default:
      ON_SAVE
    • saveMode

      SaveMode saveMode
      Save mode for the session. The default is SaveMode.ON_SET_ATTRIBUTE, which only saves changes made to session.
      Returns:
      the save mode
      Since:
      2.2.0
      Default:
      ON_SET_ATTRIBUTE