cache: Short TTL negative cache for 404/410 depot objects
CI / vulncheck (pull_request) Successful in 14s
CI / check-and-test (pull_request) Successful in 41s

Stop re-fetching gone depot objects on every miss: store 404/410 in the
existing VFS cache under the same key with a short TTL (default 5m).
This commit is contained in:
2026-09-08 16:40:03 +00:00
parent 8eb31143e5
commit 036ea1ea7f
10 changed files with 550 additions and 89 deletions
+38
View File
@@ -156,6 +156,44 @@ func TestValidate(t *testing.T) {
}(),
wantErr: false,
},
{
name: "valid negative_ttl duration",
cfg: func() Config {
c := GetDefaultConfig()
c.Cache.NegativeTTL = "1m"
return c
}(),
wantErr: false,
},
{
name: "empty negative_ttl ok",
cfg: func() Config {
c := GetDefaultConfig()
c.Cache.NegativeTTL = ""
return c
}(),
wantErr: false,
},
{
name: "invalid negative_ttl",
cfg: func() Config {
c := GetDefaultConfig()
c.Cache.NegativeTTL = "not-a-duration"
return c
}(),
wantErr: true,
errSub: "invalid cache.negative_ttl",
},
{
name: "negative duration negative_ttl",
cfg: func() Config {
c := GetDefaultConfig()
c.Cache.NegativeTTL = "-1s"
return c
}(),
wantErr: true,
errSub: "invalid cache.negative_ttl",
},
}
for _, tt := range tests {