MCPcopy Create free account
hub / github.com/allegro/bigcache / TestCacheEntryStats

Function TestCacheEntryStats

bigcache_test.go:649–671  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

647 assertEqual(t, stats.DelMisses, int64(10))
648}
649func TestCacheEntryStats(t *testing.T) {
650 t.Parallel()
651
652 // given
653 cache, _ := New(context.Background(), Config{
654 Shards: 8,
655 LifeWindow: time.Second,
656 MaxEntriesInWindow: 1,
657 MaxEntrySize: 256,
658 StatsEnabled: true,
659 })
660
661 cache.Set("key0", []byte("value"))
662
663 for i := 0; i < 10; i++ {
664 _, err := cache.Get("key0")
665 noError(t, err)
666 }
667
668 // then
669 keyMetadata := cache.KeyMetadata("key0")
670 assertEqual(t, uint32(10), keyMetadata.RequestCount)
671}
672
673func TestCacheRestStats(t *testing.T) {
674 t.Parallel()

Callers

nothing calls this directly

Calls 6

NewFunction · 0.85
SetMethod · 0.80
KeyMetadataMethod · 0.80
noErrorFunction · 0.70
assertEqualFunction · 0.70
GetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…