Interface ToolIndexEvictionStrategy

All Known Implementing Classes:
AlwaysEvictStrategy, CompositeEvictionStrategy, LruEvictionStrategy, NeverEvictStrategy, TtlEvictionStrategy

public interface ToolIndexEvictionStrategy
Strategy that decides which session tool indexes should be evicted.

onAccess(String) is called at the start of every request. Any session IDs it returns are cleared from the ToolIndex, after which onRemoved(String) is called so the strategy can drop its own internal tracking state.

Common strategies include: never evicting (indexes persist until explicitly removed), always evicting (fresh re-index on every request), LRU eviction (cap on active session count), TTL eviction (idle sessions expire after a configured duration), and composite eviction (union of multiple strategies).

Since:
2.0.0
Author:
Christian Tzolov
  • Method Summary

    Modifier and Type
    Method
    Description
    onAccess(String sessionId)
    Called each time a session is accessed at the start of request processing.
    void
    onRemoved(String sessionId)
    Called after a session's tool index has been cleared — either because this strategy returned it from onAccess(java.lang.String), or because of an explicit eviction request.
  • Method Details

    • onAccess

      Set<String> onAccess(String sessionId)
      Called each time a session is accessed at the start of request processing.

      Implementations should update their internal tracking state for sessionId and return the set of session IDs whose tool indexes must now be cleared. The returned set must never include the currently-accessed sessionId.

      Parameters:
      sessionId - the session being accessed
      Returns:
      session IDs to evict; never null, may be empty
    • onRemoved

      void onRemoved(String sessionId)
      Called after a session's tool index has been cleared — either because this strategy returned it from onAccess(java.lang.String), or because of an explicit eviction request.

      Implementations should remove any internal tracking state for the evicted session.

      Parameters:
      sessionId - the session that was evicted