Documentation
¶
Overview ¶
Package cache provides a trigram-based similarity LRU cache for deduplicating tool results.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SearchCache ¶
type SearchCache struct {
// contains filtered or unexported fields
}
SearchCache provides lightweight caching with trigram-based semantic similarity. LRU eviction is O(1) via container/list. Similarity scan uses RLock to allow concurrent reads; write lock is only acquired for LRU promotion and eviction.
func NewSearchCache ¶
func NewSearchCache(maxEntries int, ttl time.Duration) *SearchCache
NewSearchCache creates a new cache with the given capacity and TTL per entry.
func (*SearchCache) Get ¶
func (sc *SearchCache) Get(query string) (string, bool)
Get checks if a similar query exists in cache. Phase 1: read-only scan under RLock. Phase 2: LRU promotion under WLock (re-validates key is still present).
func (*SearchCache) Put ¶
func (sc *SearchCache) Put(query string, results string)
Put adds or updates a query result in the cache.