cache

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoltCache

type BoltCache struct {
	// contains filtered or unexported fields
}

BoltCache implements memory.HotCache using bbolt for L0 fact caching.

func NewBoltCache

func NewBoltCache(path string) (*BoltCache, error)

NewBoltCache opens or creates a bbolt database for caching.

func NewBoltCacheFromDB

func NewBoltCacheFromDB(db *bolt.DB) (*BoltCache, error)

NewBoltCacheInMemory creates an in-memory bolt cache (for testing). bbolt doesn't support true in-memory, so we use a temp file.

func (*BoltCache) Close

func (c *BoltCache) Close() error

Close closes the bbolt database.

func (*BoltCache) GetL0Facts

func (c *BoltCache) GetL0Facts(_ context.Context) ([]*memory.Fact, error)

GetL0Facts returns all cached L0 (project-level) facts.

func (*BoltCache) InvalidateFact

func (c *BoltCache) InvalidateFact(_ context.Context, id string) error

InvalidateFact removes a single fact from the cache.

func (*BoltCache) WarmUp

func (c *BoltCache) WarmUp(_ context.Context, facts []*memory.Fact) error

WarmUp populates the cache with a batch of L0 facts.

type CachedEmbedder

type CachedEmbedder struct {
	// contains filtered or unexported fields
}

CachedEmbedder wraps an Embedder and caches results in BoltDB (v3.4). Avoids recomputing embeddings for the same text, especially useful for ONNX mode where inference is expensive.

func NewCachedEmbedder

func NewCachedEmbedder(inner vectorstore.Embedder, db *bolt.DB) (*CachedEmbedder, error)

NewCachedEmbedder creates a caching wrapper around any Embedder.

func (*CachedEmbedder) Dimension

func (c *CachedEmbedder) Dimension() int

Dimension delegates to inner embedder.

func (*CachedEmbedder) Embed

func (c *CachedEmbedder) Embed(ctx context.Context, text string) ([]float64, error)

Embed returns cached embedding or computes and caches a new one.

func (*CachedEmbedder) Mode

Mode delegates to inner embedder.

func (*CachedEmbedder) Name

func (c *CachedEmbedder) Name() string

Name returns the inner embedder name with cache prefix.

func (*CachedEmbedder) Stats

func (c *CachedEmbedder) Stats() (hits, misses int)

Stats returns cache hit/miss statistics.

Jump to

Keyboard shortcuts

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