Class RedisSessionRepository

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

public class RedisSessionRepository extends Object implements org.springframework.session.SessionRepository<org.springframework.session.data.redis.RedisSessionRepository.RedisSession>
A SessionRepository implementation that uses Spring Data's RedisOperations to store sessions is Redis.

This implementation does not support publishing of session events.

Since:
2.2.0
  • Field Details

    • DEFAULT_KEY_NAMESPACE

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

    • RedisSessionRepository

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

    • setDefaultMaxInactiveInterval

      public void setDefaultMaxInactiveInterval(Duration defaultMaxInactiveInterval)
      Set the default maxInactiveInterval.
      Parameters:
      defaultMaxInactiveInterval - the default maxInactiveInterval
    • setKeyNamespace

      @Deprecated public void setKeyNamespace(String keyNamespace)
      Deprecated.
      since 2.4.0 in favor of setRedisKeyNamespace(String)
      Set the key namespace.
      Parameters:
      keyNamespace - the key namespace
    • setRedisKeyNamespace

      public void setRedisKeyNamespace(String namespace)
      Set the Redis key namespace.
      Parameters:
      namespace - the Redis key namespace
    • setFlushMode

      public void setFlushMode(org.springframework.session.FlushMode flushMode)
      Set the flush mode.
      Parameters:
      flushMode - the flush mode
    • setSaveMode

      public void setSaveMode(org.springframework.session.SaveMode saveMode)
      Set the save mode.
      Parameters:
      saveMode - the save mode
    • createSession

      public org.springframework.session.data.redis.RedisSessionRepository.RedisSession createSession()
      Specified by:
      createSession in interface org.springframework.session.SessionRepository<org.springframework.session.data.redis.RedisSessionRepository.RedisSession>
    • save

      public void save(org.springframework.session.data.redis.RedisSessionRepository.RedisSession session)
      Specified by:
      save in interface org.springframework.session.SessionRepository<org.springframework.session.data.redis.RedisSessionRepository.RedisSession>
    • findById

      public org.springframework.session.data.redis.RedisSessionRepository.RedisSession findById(String sessionId)
      Specified by:
      findById in interface org.springframework.session.SessionRepository<org.springframework.session.data.redis.RedisSessionRepository.RedisSession>
    • deleteById

      public void deleteById(String sessionId)
      Specified by:
      deleteById in interface org.springframework.session.SessionRepository<org.springframework.session.data.redis.RedisSessionRepository.RedisSession>
    • getSessionRedisOperations

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