Keep variant content types in memory for cache hits (closes #70)

Cache.metaCache was declared and never used, so every hit read and
parsed the variant's .meta file. It is now an LRU of up to 10,000
content types (hashicorp/golang-lru/v2), filled by StoreVariant and by
GetVariant after it reads a .meta file. For a variant it holds, Lookup
skips the disk check and GetVariant skips the .meta read; the variant
file is still opened and its size taken from it. Eviction removes the
entry before deleting the files, and GetVariant removes it when the
file will not open, so a missing variant is never served. The cap is a
constant, not a setting. README.md describes it.

Model: opus-5-5
This commit is contained in:
2026-09-29 09:28:28 +00:00
parent 33c958ad1c
commit ffe64d5fe0
7 changed files with 89 additions and 28 deletions
+9
View File
@@ -29,6 +29,15 @@ P2: security: referer blacklist
# Completed Steps
- 2026-09-29 variant content types kept in memory (closes #70):
`Cache.metaCache` holds the content types of up to 10,000 variants in an LRU
(`github.com/hashicorp/golang-lru/v2`), filled by `StoreVariant` and by
`GetVariant` after it reads a `.meta` file; for a variant it holds, `Lookup`
skips the check of the disk and `GetVariant` skips the `.meta` read, still
opening the variant file and taking the size from it; eviction removes the
entry before deleting the files, and `GetVariant` removes it when the file
will not open; the cap is a constant, not a setting; the unused `variantMeta`
type is gone; `README.md` describes it.
- 2026-09-29 maintenance mode refuses image requests (closes #71): while
`maintenance_mode` is on, `/v1/image/` and `/v1/e/` answer 503 with a
`Retry-After` header and the JSON error body, from one middleware in