Interface SessionStore
- All Superinterfaces:
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 Summary
Modifier and TypeMethodDescriptionintClears all expired sessions.findSessions(String pattern) Gets sessions that match a pattern.Gets all active session IDs.getRemainingTTL(String conversationId) Gets the remaining TTL for a context.booleanRefreshes the TTL for a context, resetting it to its original duration.voidsaveWithTTL(ConversationPersistenceSnapshot snapshot, Duration ttl) Saves a snapshot with a time-to-live (TTL).booleanSets or updates the TTL for an existing context.Methods inherited from interface ContextStore
delete, exists, getLastModified, load, loadContext, save, saveContext
-
Method Details
-
saveWithTTL
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 savettl- time-to-live duration- Throws:
IllegalArgumentException- if snapshot is null
-
setTTL
-
getRemainingTTL
-
refresh
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
-
findSessions
-
clearExpired
int clearExpired()Clears all expired sessions. Some implementations may do this automatically.- Returns:
- number of sessions cleared
-