test: add failing tests for cache_max_bytes config and cache eviction

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.
This commit is contained in:
2026-08-07 20:58:03 +00:00
parent 61f42e6602
commit 3963ec31c1
6 changed files with 1058 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"io"
"log/slog"
"path/filepath"
"time"
@@ -27,6 +28,16 @@ type CacheConfig struct {
StateDir string
CacheTTL time.Duration
NegativeTTL time.Duration
// MaxBytes is the disk cache size limit in bytes. Zero disables
// the disk cache entirely (no reads, no writes, no eviction); the
// config layer supplies the computed default when the operator
// omits cache_max_bytes.
MaxBytes int64
// Logger receives accounting and eviction log output. A nil
// Logger means slog.Default().
Logger *slog.Logger
}
// variantMeta stores content type for fast cache hits without reading .meta file.