Red phase for #51: covers strict cache_max_bytes parsing (invalid explicit values abort naming key and value), the computed default of max(75% of free space, 500 MiB) via an injectable free-space probe, explicit-value-no-floor, zero-disables-cache, size accounting over source blobs and variants, LRU eviction under the limit, the multi-referenced blob case, write-pressure and periodic eviction triggers, and startup reconciliation. Minimal API skeletons keep the tree compiling and lint-clean; only the new tests fail.
42 lines
1.5 KiB
Go
42 lines
1.5 KiB
Go
package imgcache
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
// DefaultEvictionInterval is how often the background evictor checks
|
|
// cache usage against the configured limit, in addition to the
|
|
// write-pressure wakeups triggered by stores.
|
|
const DefaultEvictionInterval = 5 * time.Minute
|
|
|
|
// UsageBytes returns the total number of bytes of cache content
|
|
// tracked in the database (source content blobs plus processed
|
|
// variants). It never scans the cache directories.
|
|
func (c *Cache) UsageBytes(_ context.Context) (int64, error) {
|
|
// Red phase: implementation follows the failing tests.
|
|
return 0, nil
|
|
}
|
|
|
|
// EvictToLimit evicts least-recently-used cache entries until total
|
|
// tracked usage is at or below the configured MaxBytes limit. It is a
|
|
// no-op when the cache is disabled (MaxBytes zero).
|
|
func (c *Cache) EvictToLimit(_ context.Context) error {
|
|
// Red phase: implementation follows the failing tests.
|
|
return nil
|
|
}
|
|
|
|
// StartEviction launches the background eviction goroutine, which
|
|
// reconciles the database accounting with the cache directories once
|
|
// at startup and then evicts to the configured limit on the given
|
|
// periodic interval and on write-pressure notifications.
|
|
func (c *Cache) StartEviction(_ time.Duration) {
|
|
// Red phase: implementation follows the failing tests.
|
|
}
|
|
|
|
// StopEviction stops the background eviction goroutine and waits for
|
|
// it to exit. It is safe to call when eviction was never started.
|
|
func (c *Cache) StopEviction() {
|
|
// Red phase: implementation follows the failing tests.
|
|
}
|