Keep variant content types in memory for cache hits (closes #70)
check / check (push) Successful in 14s

Cache.metaCache was declared and never used, so every cache hit read
and parsed the variant's .meta file. It is now an LRU
(github.com/hashicorp/golang-lru/v2) of up to 10,000 variants' content
types, filled by StoreVariant and by a read of a .meta file, so a hit
for a variant it holds skips the .meta read. Only a type from a .meta
file or a store ever enters memory, never the application/octet-stream
fallback, and a stored type is never replaced by an older one from
disk. The variant file itself is still opened on every hit, so nothing
is served from memory alone.

Model: opus-5-5
This commit was merged in pull request #157.
This commit is contained in:
2026-09-29 12:00:10 +02:00
parent 99735f479b
commit bce8860c2e
9 changed files with 460 additions and 28 deletions
@@ -24,6 +24,7 @@ const (
testHostExample = "example.com"
testPathCat = "/photos/cat.jpg"
testContentTypeJPEG = "image/jpeg"
testContentTypeWebP = "image/webp"
testHeaderContentType = "Content-Type"
)