diff --git a/pkg/api/souin.go b/pkg/api/souin.go index 1508cc55e..c57393d4d 100644 --- a/pkg/api/souin.go +++ b/pkg/api/souin.go @@ -85,10 +85,12 @@ func (s *SouinAPI) BulkDelete(key string, purge bool) { mapping.Mapping[k] = v } - buf := bytes.NewBuffer([]byte{}) - if gob.NewEncoder(buf).Encode(mapping) == nil { - _ = current.Set(core.MappingKeyPrefix+key, buf.Bytes(), 0) + v, e := proto.Marshal(&mapping) + if e != nil { + fmt.Println("Impossible to re-encode the mapping", core.MappingKeyPrefix+key) + current.Delete(core.MappingKeyPrefix + key) } + _ = current.Set(core.MappingKeyPrefix+key, v, storageToInfiniteTTLMap[current.Name()]) } } diff --git a/plugins/caddy/httpcache_test.go b/plugins/caddy/httpcache_test.go index 4072c1673..219ecd5ff 100644 --- a/plugins/caddy/httpcache_test.go +++ b/plugins/caddy/httpcache_test.go @@ -1034,15 +1034,7 @@ func TestExpires(t *testing.T) { } } - cacheChecker(caddyTester, "/expires-only", "Hello, expires-only!", int(expiresValue.Sub(time.Now()).Seconds())-1) + cacheChecker(caddyTester, "/expires-only", "Hello, expires-only!", int(time.Until(expiresValue)-1)) cacheChecker(caddyTester, "/expires-with-max-age", "Hello, expires-with-max-age!", 59) cacheChecker(caddyTester, "/expires-with-s-maxage", "Hello, expires-with-s-maxage!", 4) } - -type testCancelHandler struct{} - -func (t *testCancelHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - fmt.Println("Request") - time.Sleep(time.Second) - _, _ = w.Write([]byte("Hello, cancel-handler!")) -}