Class FileSessionStore

java.lang.Object
io.karatelabs.http.FileSessionStore
All Implemented Interfaces:
SessionStore

public class FileSessionStore extends Object implements SessionStore
File-based implementation of SessionStore. Each session is stored as a JSON file in the configured directory. Suitable for single-instance deployments where sessions must survive restarts (e.g., Docker containers with volume mounts).
  • Constructor Details

    • FileSessionStore

      public FileSessionStore(Path directory)
  • Method Details

    • create

      public Session create(int expirySeconds)
      Description copied from interface: SessionStore
      Create a new session with the specified expiry time.
      Specified by:
      create in interface SessionStore
      Parameters:
      expirySeconds - number of seconds until the session expires
      Returns:
      newly created session with unique ID
    • get

      public Session get(String id)
      Description copied from interface: SessionStore
      Retrieve a session by its ID.
      Specified by:
      get in interface SessionStore
      Parameters:
      id - the session ID
      Returns:
      the session if found and not expired, null otherwise
    • save

      public void save(Session session)
      Description copied from interface: SessionStore
      Save/update a session in the store.
      Specified by:
      save in interface SessionStore
      Parameters:
      session - the session to save
    • delete

      public void delete(String id)
      Description copied from interface: SessionStore
      Delete a session from the store.
      Specified by:
      delete in interface SessionStore
      Parameters:
      id - the session ID to delete