Class ReactiveRedisSessionRepository

java.lang.Object
org.springframework.session.data.redis.ReactiveRedisSessionRepository
All Implemented Interfaces:
ReactiveSessionRepository<org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession>

public class ReactiveRedisSessionRepository extends Object implements ReactiveSessionRepository<org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession>
A ReactiveSessionRepository that is implemented using Spring Data's ReactiveRedisOperations.
Since:
2.2.0
  • Field Details

    • DEFAULT_NAMESPACE

      public static final String DEFAULT_NAMESPACE
      The default namespace for each key and channel in Redis used by Spring Session.
      See Also:
  • Constructor Details

    • ReactiveRedisSessionRepository

      public ReactiveRedisSessionRepository(org.springframework.data.redis.core.ReactiveRedisOperations<String,Object> sessionRedisOperations)
      Create a new ReactiveRedisSessionRepository instance.
      Parameters:
      sessionRedisOperations - the ReactiveRedisOperations to use for managing sessions
  • Method Details

    • setRedisKeyNamespace

      public void setRedisKeyNamespace(String namespace)
    • setDefaultMaxInactiveInterval

      public void setDefaultMaxInactiveInterval(Duration defaultMaxInactiveInterval)
      Set the maximum inactive interval in seconds between requests before newly created sessions will be invalidated. A negative time indicates that the session will never time out. The default is 30 minutes.
      Parameters:
      defaultMaxInactiveInterval - the default maxInactiveInterval
    • setDefaultMaxInactiveInterval

      @Deprecated(since="3.0.0") public void setDefaultMaxInactiveInterval(int defaultMaxInactiveInterval)
      Deprecated.
      Set the maximum inactive interval in seconds between requests before newly created sessions will be invalidated. A negative time indicates that the session will never time out. The default is 1800 (30 minutes).
      Parameters:
      defaultMaxInactiveInterval - the default maxInactiveInterval in seconds
    • setSaveMode

      public void setSaveMode(SaveMode saveMode)
      Set the save mode.
      Parameters:
      saveMode - the save mode
    • getSessionRedisOperations

      public org.springframework.data.redis.core.ReactiveRedisOperations<String,Object> getSessionRedisOperations()
      Returns the ReactiveRedisOperations used for sessions.
      Returns:
      the ReactiveRedisOperations used for sessions
    • createSession

      public reactor.core.publisher.Mono<org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession> createSession()
      Description copied from interface: ReactiveSessionRepository
      Creates a new Session that is capable of being persisted by this ReactiveSessionRepository.

      This allows optimizations and customizations in how the Session is persisted. For example, the implementation returned might keep track of the changes ensuring that only the delta needs to be persisted on a save.

      Specified by:
      createSession in interface ReactiveSessionRepository<org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession>
      Returns:
      a new Session that is capable of being persisted by this ReactiveSessionRepository
    • save

      public reactor.core.publisher.Mono<Void> save(org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession session)
      Description copied from interface: ReactiveSessionRepository
      Ensures the Session created by ReactiveSessionRepository.createSession() is saved.

      Some implementations may choose to save as the Session is updated by returning a Session that immediately persists any changes. In this case, this method may not actually do anything.

      Specified by:
      save in interface ReactiveSessionRepository<org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession>
      Parameters:
      session - the Session to save
      Returns:
      indicator of operation completion
    • findById

      public reactor.core.publisher.Mono<org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession> findById(String id)
      Description copied from interface: ReactiveSessionRepository
      Gets the Session by the Session.getId() or null if no Session is found.
      Specified by:
      findById in interface ReactiveSessionRepository<org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession>
      Parameters:
      id - the Session.getId() to lookup
      Returns:
      the Session by the Session.getId() or null if no Session is found.
    • deleteById

      public reactor.core.publisher.Mono<Void> deleteById(String id)
      Description copied from interface: ReactiveSessionRepository
      Deletes the Session with the given Session.getId() or does nothing if the Session is not found.
      Specified by:
      deleteById in interface ReactiveSessionRepository<org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession>
      Parameters:
      id - the Session.getId() to delete
      Returns:
      indicator of operation completion
    • setSessionIdGenerator

      public void setSessionIdGenerator(SessionIdGenerator sessionIdGenerator)
      Set the SessionIdGenerator to use to generate session ids.
      Parameters:
      sessionIdGenerator - the SessionIdGenerator to use
      Since:
      3.2
    • setRedisSessionMapper

      public void setRedisSessionMapper(BiFunction<String,Map<String,Object>,reactor.core.publisher.Mono<MapSession>> redisSessionMapper)
      Set the BiFunction used to convert a Map to a MapSession.
      Parameters:
      redisSessionMapper - the mapper to use, cannot be null
      Since:
      3.2