Help us shape the future of Go! Take the 2026 Go Developer Survey

cache

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package cache owns the user-level, content-addressed embedding cache.

Index

Constants

View Source
const (
	EnvPath       = "GRAFO_EMBED_CACHE"
	SchemaVersion = 1
)

Variables

This section is empty.

Functions

func ResolvePath

func ResolvePath() (string, error)

Types

type Cache

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

func Open

func Open(ctx context.Context, path string) (*Cache, error)

func OpenDefault

func OpenDefault(ctx context.Context) (*Cache, error)

func OpenReadOnly

func OpenReadOnly(ctx context.Context, path string) (*Cache, error)

OpenReadOnly opens an existing compatible cache without creating files, changing permissions, checkpointing, or updating access timestamps.

func OpenWithOptions

func OpenWithOptions(ctx context.Context, path string, options Options) (*Cache, error)

func (*Cache) Close

func (c *Cache) Close() error

func (*Cache) Load

func (c *Cache) Load(ctx context.Context, keys []semantic.CacheKey) (map[semantic.CacheKey][]float32, error)

func (*Cache) Path

func (c *Cache) Path() string

func (*Cache) Prune

func (c *Cache) Prune(ctx context.Context, options PruneOptions) (PruneReport, error)

func (*Cache) Status

func (c *Cache) Status(ctx context.Context) (Status, error)

func (*Cache) Store

func (c *Cache) Store(ctx context.Context, entries []semantic.CacheEntry) error

type ModelStatus

type ModelStatus struct {
	Model        string `json:"model"`
	Rows         int64  `json:"rows"`
	Dimensions   []int  `json:"dimensions"`
	BlobBytes    int64  `json:"blob_bytes"`
	OldestUsedAt string `json:"oldest_used_at,omitempty"`
	NewestUsedAt string `json:"newest_used_at,omitempty"`
}

type Options

type Options struct {
	Now           func() time.Time
	TouchInterval time.Duration
}

type PruneOptions

type PruneOptions struct {
	Model     string
	OlderThan time.Duration
	MaxBytes  *int64
	DryRun    bool
}

type PruneReport

type PruneReport struct {
	DryRun             bool  `json:"dry_run"`
	DeletedRows        int64 `json:"deleted_rows"`
	FreedBlobBytes     int64 `json:"freed_blob_bytes"`
	RemainingRows      int64 `json:"remaining_rows"`
	RemainingBlobBytes int64 `json:"remaining_blob_bytes"`
	DatabaseBytes      int64 `json:"database_bytes"`
	WALBytes           int64 `json:"wal_bytes"`
	SHMBytes           int64 `json:"shm_bytes"`
	ReclaimableBytes   int64 `json:"reclaimable_bytes"`
}

type Status

type Status struct {
	Path             string        `json:"path"`
	SchemaVersion    int           `json:"schema_version"`
	Models           []ModelStatus `json:"models"`
	Rows             int64         `json:"rows"`
	BlobBytes        int64         `json:"blob_bytes"`
	DatabaseBytes    int64         `json:"database_bytes"`
	WALBytes         int64         `json:"wal_bytes"`
	SHMBytes         int64         `json:"shm_bytes"`
	ReclaimableBytes int64         `json:"reclaimable_bytes"`
	OldestUsedAt     string        `json:"oldest_used_at,omitempty"`
	NewestUsedAt     string        `json:"newest_used_at,omitempty"`
}

Jump to

Keyboard shortcuts

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