Skip to content

Commit cbd6df8

Browse files
committed
fix(configuration): load mapping_eviction_interval properly
1 parent 2052932 commit cbd6df8

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

plugins/caddy/configuration.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ type DefaultCache struct {
6060
Stale configurationtypes.Duration `json:"stale"`
6161
// Disable the coalescing system.
6262
DisableCoalescing bool `json:"disable_coalescing"`
63+
// MappingEvictionInterval interval between eviction
64+
MappingEvictionInterval configurationtypes.Duration `json:"mapping_eviction_interval"`
6365
}
6466

6567
// GetAllowedHTTPVerbs returns the allowed verbs to cache
@@ -107,6 +109,11 @@ func (d *DefaultCache) GetEtcd() configurationtypes.CacheProvider {
107109
return d.Etcd
108110
}
109111

112+
// GetMappingEvictionInterval returns the interval between eviction
113+
func (d *DefaultCache) GetMappingEvictionInterval() time.Duration {
114+
return d.MappingEvictionInterval.Duration
115+
}
116+
110117
// GetMode returns mdoe configuration
111118
func (d *DefaultCache) GetMode() string {
112119
return d.Mode
@@ -763,6 +770,12 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isGlobal boo
763770
}
764771
case "disable_coalescing":
765772
cfg.DefaultCache.DisableCoalescing = true
773+
case "mapping_eviction_interval":
774+
args := h.RemainingArgs()
775+
interval, err := time.ParseDuration(args[0])
776+
if err == nil {
777+
cfg.DefaultCache.MappingEvictionInterval.Duration = interval
778+
}
766779
case "disable_surrogate_key":
767780
cfg.SurrogateKeyDisabled = true
768781
default:

plugins/caddy/httpcache.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,9 @@ func parseCaddyfileGlobalOption(h *caddyfile.Dispenser, _ interface{}) (interfac
296296
TTL: configurationtypes.Duration{
297297
Duration: 120 * time.Second,
298298
},
299-
DefaultCacheControl: "",
300-
CacheName: "",
299+
MappingEvictionInterval: configurationtypes.Duration{Duration: time.Hour},
300+
DefaultCacheControl: "",
301+
CacheName: "",
301302
},
302303
URLs: make(map[string]configurationtypes.URL),
303304
}

plugins/souin/agnostic/configuration_parser.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,10 @@ func parseDefaultCache(dcConfiguration map[string]interface{}) *configurationtyp
104104
Path: "",
105105
Configuration: nil,
106106
},
107-
Regex: configurationtypes.Regex{},
108-
TTL: configurationtypes.Duration{},
109-
DefaultCacheControl: "",
107+
Regex: configurationtypes.Regex{},
108+
TTL: configurationtypes.Duration{},
109+
MappingEvictionInterval: configurationtypes.Duration{Duration: time.Hour},
110+
DefaultCacheControl: "",
110111
}
111112
for defaultCacheK, defaultCacheV := range dcConfiguration {
112113
switch defaultCacheK {
@@ -195,6 +196,11 @@ func parseDefaultCache(dcConfiguration map[string]interface{}) *configurationtyp
195196
}
196197
}
197198
}
199+
case "mapping_eviction_interval":
200+
eviction, err := time.ParseDuration(defaultCacheV.(string))
201+
if err == nil {
202+
dc.MappingEvictionInterval = configurationtypes.Duration{Duration: eviction}
203+
}
198204
case "mode":
199205
dc.Mode, _ = defaultCacheV.(string)
200206
case "nats":

0 commit comments

Comments
 (0)