MCPcopy
hub / github.com/grafana/tempo / newLogClusterCache

Function newLogClusterCache

pkg/drain/log_cluster_cache.go:15–30  ·  view source on GitHub ↗
(maxAge time.Duration, maxSize int, evictions prometheus.Counter, expired prometheus.Counter)

Source from the content-addressed store, hash-verified

13}
14
15func newLogClusterCache(maxAge time.Duration, maxSize int, evictions prometheus.Counter, expired prometheus.Counter) *logClusterCache {
16 return &logClusterCache{
17 cache: otter.Must(&otter.Options[int, *LogCluster]{
18 MaximumSize: maxSize,
19 ExpiryCalculator: otter.ExpiryAccessing[int, *LogCluster](maxAge),
20 OnAtomicDeletion: func(e otter.DeletionEvent[int, *LogCluster]) {
21 switch e.Cause {
22 case otter.CauseOverflow:
23 evictions.Inc()
24 case otter.CauseExpiration:
25 expired.Inc()
26 }
27 },
28 }),
29 }
30}
31
32func (c *logClusterCache) Values() iter.Seq[*LogCluster] {
33 return c.cache.Values()

Callers 7

NewFunction · 0.85

Calls 1

IncMethod · 0.65