cache

package
v0.41.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2026 License: Apache-2.0 Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL