Have Lookup check the disk for variants held in memory too (closes #70)
Lookup again counts a variant as present only when its file exists. Treating a variant held in memory as present saved one check of the disk, but no test covered it, and GetVariant opens the file anyway. Model: opus-5-5
This commit is contained in:
@@ -159,15 +159,13 @@ type LookupResult struct {
|
||||
CacheStatus CacheStatus
|
||||
}
|
||||
|
||||
// Lookup checks if a processed variant exists on disk: a variant held
|
||||
// in metaCache counts as present without a check of the disk. Hits
|
||||
// touch the variant's LRU timestamp; a disabled cache always misses.
|
||||
// Lookup checks if a processed variant exists on disk. Hits touch the
|
||||
// variant's LRU timestamp; a disabled cache always misses.
|
||||
func (c *Cache) Lookup(ctx context.Context, req *ImageRequest) (*LookupResult, error) {
|
||||
cacheKey := CacheKey(req)
|
||||
|
||||
// Check memory, then variant storage - no DB needed for cache hits
|
||||
if !c.disabled &&
|
||||
(c.metaCache.Contains(cacheKey) || c.variants.Exists(cacheKey)) {
|
||||
// Check variant storage directly - no DB needed for cache hits
|
||||
if !c.disabled && c.variants.Exists(cacheKey) {
|
||||
c.touchVariant(ctx, cacheKey)
|
||||
|
||||
return &LookupResult{
|
||||
|
||||
Reference in New Issue
Block a user