cache: Short TTL negative cache for 404/410 depot objects
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user