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

Function New

pkg/cache/reclaimable/reclaimable.go:15–25  ·  view source on GitHub ↗

New reclaimable cache. Must provide the function to populate values. The maximum number of values can be optionally set (zero means unlimited).

(f func(TKey) TValue, maxLen int)

Source from the content-addressed store, hash-verified

13// New reclaimable cache. Must provide the function to populate values. The maximum number of values
14// can be optionally set (zero means unlimited).
15func New[TKey comparable, TValue any](f func(TKey) TValue, maxLen int) Cache[TKey, TValue] {
16 return Cache[TKey, TValue]{
17 max: maxLen,
18 f: f,
19 pool: &sync.Pool{
20 New: func() any {
21 return make(map[TKey]TValue)
22 },
23 },
24 }
25}
26
27func (c Cache[TKey, TValue]) Get(key TKey) TValue {
28 m := c.pool.Get().(map[TKey]TValue)

Callers 2

NewFunction · 0.92
NewFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected