Skip to content

Commit

Permalink
wip(surrogate): invalidate
Browse files Browse the repository at this point in the history
  • Loading branch information
darkweak committed Aug 17, 2024
1 parent 534c572 commit 09b11b7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pkg/storage/defaultProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package storage

import (
"bytes"
"fmt"
"net/http"
"regexp"
"strings"
Expand Down Expand Up @@ -56,6 +57,8 @@ func (provider *Default) MapKeys(prefix string) map[string]string {

return true
}

keys[key.(string)] = fmt.Sprint(value)
if v, ok := value.(*core.StorageMapper); ok {
for _, v := range v.Mapping {
if v.StaleTime.AsTime().After(now) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/surrogate/providers/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ func (s *baseStorage) Store(response *http.Response, cacheKey, uri, basekey stri

urlRegexp = regexp.MustCompile("(^|" + regexp.QuoteMeta(souinStorageSeparator) + ")" + regexp.QuoteMeta(basekey) + "(" + regexp.QuoteMeta(souinStorageSeparator) + "|$)")
s.storeTag(uri, basekey, urlRegexp)
s.storeTag(uri, cacheKey, urlRegexp)

return nil
}
Expand Down Expand Up @@ -266,7 +267,7 @@ func (s *baseStorage) Invalidate(method string, headers http.Header) {

// List returns the stored keys associated to resources
func (s *baseStorage) List() map[string]string {
return s.Storage.MapKeys(surrogatePrefix)
return s.Storage.MapKeys("")
}

// Destruct method will shutdown properly the provider
Expand Down

0 comments on commit 09b11b7

Please sign in to comment.