Expand description
A cache over identify keyed by an on-disk
freshness signature. Identifying a file model reads its GGUF/safetensors
header and stats its directory; over a large shelf that repeats on every
resolution pass. The cache skips it when a model’s bytes are unchanged.
The cheap source kinds (builtin/endpoint/ollama) are never cached — their identification is a fixed profile or a small manifest read, so a cache entry would cost more than it saves.
The freshness signature is depth-1: it folds the model path and its immediate
children, not files nested deeper (an HF-cache snapshots/<ref>/config.json
or a diffusers transformer/config.json). An in-place edit below the top
level is therefore not noticed. Adding, removing, or replacing an immediate
child (the common re-download shape) is caught.
Structs§
- Identification
Cache - A freshness-keyed cache of identification results, safe to share across
threads. A cache miss (or any lock failure) falls back to a direct
identify, so the cache is only ever an optimization. A changed top-level mtime or size (an added/removed/replaced immediate child, or a rewritten file) invalidates the entry; see the module docs for the depth-1 limitation.