Skip to content

Commit

Permalink
config: add CacheAge field
Browse files Browse the repository at this point in the history
This allows operators to tune the caching metadata of responses. In
cases where updaters are split, this value may be useful to adjust
independently from the update period.

Signed-off-by: Hank Donnay <hdonnay@redhat.com>
  • Loading branch information
hdonnay committed Aug 11, 2021
1 parent f7fdc90 commit b4ec7aa
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions config/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ type Matcher struct {
//
// A value of 0 disables GC.
UpdateRetention int `yaml:"update_retention" json:"update_retention"`
// CacheAge controls how long clients should be hinted to cache responses
// for.
//
// If empty, the duration set in "Period" will be used. This means client
// may cache "stale" results for 2(Period) - 1 seconds.
CacheAge time.Duration `yaml:"cache_age,omitempty" json:"cache_age,omitempty"`
}

func (m *Matcher) Validate(combo bool) error {
Expand All @@ -62,6 +68,9 @@ func (m *Matcher) Validate(combo bool) error {
if m.UpdateRetention == 1 || m.UpdateRetention < 0 {
m.UpdateRetention = DefaultRetention
}
if m.CacheAge == 0 {
m.CacheAge = m.Period
}
if !combo {
if m.IndexerAddr == "" {
return fmt.Errorf("matcher mode requires a remote Indexer address")
Expand Down

0 comments on commit b4ec7aa

Please sign in to comment.