MCPcopy
hub / github.com/grafana/dskit / TestLRUCache_Evictions

Function TestLRUCache_Evictions

cache/lru_test.go:80–98  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

78}
79
80func TestLRUCache_Evictions(t *testing.T) {
81 const maxItems = 2
82
83 reg := prometheus.NewPedanticRegistry()
84 lru, err := WrapWithLRUCache(NewMockCache(), "test", reg, maxItems, 2*time.Hour, log.NewNopLogger())
85 require.NoError(t, err)
86
87 lru.SetMultiAsync(map[string][]byte{
88 "key_1": []byte("value_1"),
89 "key_2": []byte("value_2"),
90 "key_3": []byte("value_3"),
91 }, time.Minute)
92
93 require.NoError(t, testutil.GatherAndCompare(reg, strings.NewReader(`
94 # HELP cache_memory_items_count Total number of items currently in the in-memory cache.
95 # TYPE cache_memory_items_count gauge
96 cache_memory_items_count{name="test"} 2
97 `), "cache_memory_items_count"))
98}
99
100func TestLRUCache_SetAdd(t *testing.T) {
101 const maxItems = 10

Callers

nothing calls this directly

Calls 3

WrapWithLRUCacheFunction · 0.85
NewMockCacheFunction · 0.85
SetMultiAsyncMethod · 0.65

Tested by

no test coverage detected