Skip to content

Commit

Permalink
clarify purpose of periodicallyClearCache and remove overkill languag…
Browse files Browse the repository at this point in the history
…e about memory growth to reflect reality
  • Loading branch information
zcross committed Aug 11, 2023
1 parent 492293f commit caca5b5
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ func (c *serviceStrategyTTLCache) put(
}
}

// periodicallyClearCache provides a secondary "cleanup" mechanism motivated by wanting to guarantee
// that the memory usage of this serviceStrategyTTLCache does not grow unbounded over long periods of collector uptime.
// Ideally, this is really unnecessary because the get/put access pattern suffices to maintain a small
// set of services. If that assumption is violated, this async process will periodically flush stale items.
// periodicallyClearCache periodically clears expired items from the cache and replaces the backing map with only
// valid (fresh) items. Note that this is not necessary for correctness, just preferred for memory usage hygiene.
// Client request activity drives the replacement of stale items with fresh items upon cache misses for any service.
func (c *serviceStrategyTTLCache) periodicallyClearCache(
ctx context.Context,
schedulingPeriod time.Duration,
Expand Down

0 comments on commit caca5b5

Please sign in to comment.