Skip to content

Commit

Permalink
feat(log): warn users if they use the default cache
Browse files Browse the repository at this point in the history
  • Loading branch information
darkweak committed Jul 7, 2024
1 parent 84b1908 commit d363dd2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions pkg/middleware/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func NewHTTPCacheHandler(c configurationtypes.AbstractConfigurationInterface) *S
storedStorers := core.GetRegisteredStorers()
storers := make([]types.Storer, len(storedStorers))
if len(storedStorers) == 0 {
c.GetLogger().Warn("You're running Souin with the default storage that is not optimized and for development purpose. We recommend to use at least one of the storages from https://github.com/darkweak/storages")
memoryStorer, _ := storage.Factory(c)
core.RegisterStorage(memoryStorer)
storers = append(storers, memoryStorer)
Expand Down
12 changes: 6 additions & 6 deletions plugins/caddy/httpcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,6 @@ func (s *SouinCaddyMiddleware) Provision(ctx caddy.Context) error {
return err
}

bh := middleware.NewHTTPCacheHandler(&s.Configuration)
surrogates, ok := up.LoadOrStore(surrogate_key, bh.SurrogateKeyStorer)
if ok {
bh.SurrogateKeyStorer = surrogates.(surrogates_providers.SurrogateInterface)
}

if s.Configuration.DefaultCache.Badger.Found {
e := dispatchStorage(ctx, "badger", s.Configuration.DefaultCache.Badger, s.Configuration.DefaultCache.GetStale())
if e != nil {
Expand Down Expand Up @@ -289,6 +283,12 @@ func (s *SouinCaddyMiddleware) Provision(ctx caddy.Context) error {
}
}

bh := middleware.NewHTTPCacheHandler(&s.Configuration)
surrogates, ok := up.LoadOrStore(surrogate_key, bh.SurrogateKeyStorer)
if ok {
bh.SurrogateKeyStorer = surrogates.(surrogates_providers.SurrogateInterface)
}

s.SouinBaseHandler = bh
if len(app.Storers) == 0 {
app.Storers = s.SouinBaseHandler.Storers
Expand Down

0 comments on commit d363dd2

Please sign in to comment.