Interface SessionStore

All Superinterfaces:
ContextStore

public interface SessionStore extends ContextStore
Store for session-scoped conversation contexts with automatic expiration. Typically backed by in-memory or fast cache storage like Redis. Sessions are expected to be short-lived and tied to specific tasks or user sessions.
Since:
0.1 (2025-09-22)
Author:
Andrey Santrosyan
  • Method Details

    • saveWithTTL

      void saveWithTTL(ConversationPersistenceSnapshot snapshot, Duration ttl)
      Saves a snapshot with a time-to-live (TTL). The context will be automatically deleted after the TTL expires.
      Parameters:
      snapshot - the conversation snapshot to save
      ttl - time-to-live duration
      Throws:
      IllegalArgumentException - if snapshot is null
    • setTTL

      boolean setTTL(String conversationId, Duration ttl)
      Sets or updates the TTL for an existing context.
      Parameters:
      conversationId - unique identifier for the context
      ttl - new time-to-live duration
      Returns:
      true if TTL was set, false if context doesn't exist
    • getRemainingTTL

      Duration getRemainingTTL(String conversationId)
      Gets the remaining TTL for a context.
      Parameters:
      conversationId - unique identifier for the context
      Returns:
      remaining time-to-live, or null if context doesn't exist or has no TTL
    • refresh

      boolean refresh(String conversationId)
      Refreshes the TTL for a context, resetting it to its original duration. Useful for keeping active sessions alive.
      Parameters:
      conversationId - unique identifier for the context
      Returns:
      true if TTL was refreshed, false if context doesn't exist
    • getActiveSessions

      Set<String> getActiveSessions()
      Gets all active session IDs. Useful for monitoring and cleanup operations.
      Returns:
      set of active session context IDs
    • findSessions

      Set<String> findSessions(String pattern)
      Gets sessions that match a pattern. Useful for finding related sessions (e.g., all sessions for a user).
      Parameters:
      pattern - pattern to match (implementation-specific, e.g., "user:123:*")
      Returns:
      set of matching context IDs
    • clearExpired

      int clearExpired()
      Clears all expired sessions. Some implementations may do this automatically.
      Returns:
      number of sessions cleared