| 13 | } |
| 14 | |
| 15 | func 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 | |
| 32 | func (c *logClusterCache) Values() iter.Seq[*LogCluster] { |
| 33 | return c.cache.Values() |