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

gencache

package
v0.28.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package gencache is keryx's content-addressed generation cache (R-GEN-8 / R-GLOBAL-9): a generated artefact set — a VO line's takes, a music bed, a card's illustrations — is keyed by a hash of its request (text/scene/prompt + all the settings that affect the output). Re-running a generation with unchanged inputs is a cache HIT: the takes are materialised from the cache with no provider call and no spend. The cache lives under the workspace's git-ignored, prune-able `.cache/` dir, keyed by kind + request hash, so it survives a text revert and never bloats the repo.

The cache stores the *set* of takes for a request (not per-blob), so generation variety (`--takes N`) is preserved — a hit replays the same N candidates.

Index

Constants

View Source
const CacheRoot = ".cache"

CacheRoot is the workspace-relative cache directory (git-ignored; pruned).

Variables

This section is empty.

Functions

func Dir

func Dir(ws, kind, key string) string

Dir is the cache directory for a kind (e.g. "vo", "music", "cards/03") + key hash.

func Key

func Key(fields any) (string, error)

Key hashes the request's content-affecting fields into a stable hex digest. The fields are JSON-marshalled (deterministic order), so any change — text, a setting, the model, a pronunciation dictionary — yields a different key and thus a miss.

func Read

func Read(fs afero.Fs, dir string) [][]byte

Read returns the cached blob set for a key dir in take order (1, 2, …), or nil when the dir is absent/empty (a miss). Blobs are stored as plain numbered files.

func Write

func Write(fs afero.Fs, dir string, blobs [][]byte) error

Write stores the blob set under the key dir as numbered files (1, 2, …). It writes the full set to a sibling temp dir first and only then swaps it into place, so a mid-write failure (disk full, cancel, crash) leaves the prior entry intact rather than a truncated one — Read never sees a partial set it would treat as a hit.

Types

This section is empty.

Jump to

Keyboard shortcuts

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