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

Function TestCacheCapacity

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

Source from the content-addressed store, hash-verified

530}
531
532func TestCacheCapacity(t *testing.T) {
533 t.Parallel()
534
535 // given
536 cache, _ := New(context.Background(), Config{
537 Shards: 8,
538 LifeWindow: time.Second,
539 MaxEntriesInWindow: 1,
540 MaxEntrySize: 256,
541 })
542 keys := 1337
543
544 // when
545 for i := 0; i < keys; i++ {
546 cache.Set(fmt.Sprintf("key%d", i), []byte("value"))
547 }
548
549 // then
550 assertEqual(t, keys, cache.Len())
551 assertEqual(t, 40960, cache.Capacity())
552}
553
554func TestCacheInitialCapacity(t *testing.T) {
555 t.Parallel()

Callers

nothing calls this directly

Calls 5

NewFunction · 0.85
SetMethod · 0.80
assertEqualFunction · 0.70
LenMethod · 0.45
CapacityMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…