Versions in this module Expand all Collapse all v0 v0.2.0 Jun 18, 2026 v0.1.0 Jun 17, 2026 Changes in this version + var ErrNoEmbedder = errors.New("semcache: an Embedder is required") + type Cache interface + Lookup func(ctx context.Context, q Query) (Entry, bool, error) + Stats func() Stats + Store func(ctx context.Context, q Query, resp Entry) error + type Embedder interface + Embed func(ctx context.Context, text string) ([]float32, error) + type EmbedderFunc func(ctx context.Context, text string) ([]float32, error) + func (f EmbedderFunc) Embed(ctx context.Context, text string) ([]float32, error) + type Entry struct + CreatedAt time.Time + Epoch string + Meta map[string]string + Response string + type FloorVerifier struct + func (FloorVerifier) Verify(context.Context, string, store.Record) (bool, error) + type HashEmbedder struct + func NewHashEmbedder(dims int) *HashEmbedder + func (h *HashEmbedder) Embed(_ context.Context, text string) ([]float32, error) + type LexicalVerifier struct + MinOverlap float64 + func (v LexicalVerifier) Verify(_ context.Context, qText string, candidate store.Record) (bool, error) + type Metrics struct + type Option func(*SemanticCache) + func WithClock(now func() time.Time) Option + func WithPolicy(p Policy) Option + func WithRedactor(r *Redactor) Option + func WithStore(s store.Store) Option + func WithVerifier(v Verifier) Option + type Policy struct + Candidates int + EnforceEpoch bool + EnforceMeta bool + NegativeCache bool + SimilarityFloor float32 + TTL time.Duration + func DefaultPolicy() Policy + type Query struct + Epoch string + Meta map[string]string + Namespace string + Text string + type Redactor struct + func NewRedactor() *Redactor + func (r *Redactor) AddRule(pattern, token string) error + func (r *Redactor) Canonicalize(text string) string + func (r *Redactor) Redact(text string) string + type SemanticCache struct + func New(embed Embedder, opts ...Option) (*SemanticCache, error) + func (c *SemanticCache) Lookup(ctx context.Context, q Query) (Entry, bool, error) + func (c *SemanticCache) Stats() Stats + func (c *SemanticCache) Store(ctx context.Context, q Query, resp Entry) error + type Stats struct + Evictions uint64 + FalseHitsAvoided uint64 + Hits uint64 + Misses uint64 + Size int + Stores uint64 + func (s Stats) FalseHitRate() float64 + func (s Stats) HitRate() float64 + type Verifier interface + Verify func(ctx context.Context, qText string, candidate store.Record) (bool, error) + type VerifierFunc func(ctx context.Context, qText string, candidate store.Record) (bool, error) + func (f VerifierFunc) Verify(ctx context.Context, qText string, candidate store.Record) (bool, error)