Skip to main content

Module llm_cache

Module llm_cache 

Source
Expand description

Content-addressed cache for parsed LLM responses.

Every successful one-shot LLM call writes its parsed payload here keyed on the canonical request material (operation, model, prompts, schema, temperature, …). Subsequent calls with byte-identical inputs short-circuit the network round-trip and replay the parsed value, which is the cheapest possible recovery when the caller (eg. lgit --compose) is rerun after a transient failure or unrelated edit.

Backed by SQLite for atomic upserts and TTL-based eviction. The cache is best-effort: any failure to read/write is logged and skipped — never fatal.

Structs§

CacheMaterial
Material that uniquely identifies a one-shot LLM call. Hashed into the cache key.
LlmCache
SQLite-backed cache of LLM responses. Cheap to clone via Arc.

Functions§

compute_key
Compute a content-addressed cache key over material. Stable across runs for byte-identical inputs.
global
Get the active cache handle, if any. Cheap clone of an Arc.
init
Initialize the global LLM response cache from config. Idempotent: only the first call wins.