Class FixedDurationExpirationSessionRepository<S extends org.springframework.session.Session>

java.lang.Object
org.springframework.session.data.gemfire.expiration.repository.FixedDurationExpirationSessionRepository<S>
All Implemented Interfaces:
org.springframework.session.SessionRepository<S>

public class FixedDurationExpirationSessionRepository<S extends org.springframework.session.Session> extends Object implements org.springframework.session.SessionRepository<S>
The FixedDurationExpirationSessionRepository class is a SessionRepository implementation wrapping an existing SessionRepository, data store specific, implementation in order to implement a fixed Duration expiration policy on the Session. That is, the Session will always expire (or be considered "expired") after a fixed amount of time. Even if the user Session is still actively being accessed up to the last moment right before the Session is about to expire, the Session will expire regardless. This may be useful in certain UCs where, for security reasons, the Session must expire no matter what.
Since:
2.1.0
See Also:
  • Constructor Details

    • FixedDurationExpirationSessionRepository

      public FixedDurationExpirationSessionRepository(@NonNull org.springframework.session.SessionRepository<S> sessionRepository, @Nullable Duration expirationTimeout)
      Constructs a new instance of FixedDurationExpirationSessionRepository initialized with the given data store specific SessionRepository.
      Parameters:
      sessionRepository - SessionRepository delegate.
      expirationTimeout - Duration specifying the length of time until the Session expires.
      Throws:
      IllegalArgumentException - if SessionRepository is null.
      See Also:
  • Method Details

    • getDelegate

      @NonNull protected org.springframework.session.SessionRepository<S> getDelegate()
      Returns a reference to the data store specific SessionRepository.
      Returns:
      a reference to the data store specific SessionRepository.
      See Also:
      • SessionRepository
    • getExpirationTimeout

      public Optional<Duration> getExpirationTimeout()
      Returns:
      an Optional expiraiton timeout.
      See Also:
    • createSession

      public S createSession()
      Creates a new instance of Session. The Session instance will be managed by Apache Geode or Pivotal GemFire.
      Specified by:
      createSession in interface org.springframework.session.SessionRepository<S extends org.springframework.session.Session>
      Returns:
      a new instance of Session.
      See Also:
      • Session
    • findById

      public S findById(String id)
      Finds a Session with the given ID. This method will also perform a lazy expiration check to determine if the Session has already expired upon access, and if so, delete the Session with the given ID.
      Specified by:
      findById in interface org.springframework.session.SessionRepository<S extends org.springframework.session.Session>
      Parameters:
      id - String containing the ID identifying the Session to lookup.
      Returns:
      the Session with the given ID or null if no Session with ID exists or the Session is expired.
      See Also:
    • save

      public void save(S session)
      Saves the given Session to the underlying data (persistent) store.
      Specified by:
      save in interface org.springframework.session.SessionRepository<S extends org.springframework.session.Session>
      Parameters:
      session - Session to save.
      See Also:
      • Session
    • deleteById

      public void deleteById(String id)
      Deletes the Session identified by the given ID.
      Specified by:
      deleteById in interface org.springframework.session.SessionRepository<S extends org.springframework.session.Session>
      Parameters:
      id - String containing the ID of the Session to delete.
      See Also:
      • Session