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

Function TestCacheInitialCapacity

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

Source from the content-addressed store, hash-verified

552}
553
554func TestCacheInitialCapacity(t *testing.T) {
555 t.Parallel()
556
557 // given
558 cache, _ := New(context.Background(), Config{
559 Shards: 1,
560 LifeWindow: time.Second,
561 MaxEntriesInWindow: 2 * 1024,
562 HardMaxCacheSize: 1,
563 MaxEntrySize: 1024,
564 })
565
566 assertEqual(t, 0, cache.Len())
567 assertEqual(t, 1024*1024, cache.Capacity())
568
569 keys := 1024 * 1024
570
571 // when
572 for i := 0; i < keys; i++ {
573 cache.Set(fmt.Sprintf("key%d", i), []byte("value"))
574 }
575
576 // then
577 assertEqual(t, true, cache.Len() < keys)
578 assertEqual(t, 1024*1024, cache.Capacity())
579}
580
581func TestRemoveEntriesWhenShardIsFull(t *testing.T) {
582 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…