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

Function TestCacheReset

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

Source from the content-addressed store, hash-verified

837}
838
839func TestCacheReset(t *testing.T) {
840 t.Parallel()
841
842 // given
843 cache, _ := New(context.Background(), Config{
844 Shards: 8,
845 LifeWindow: time.Second,
846 MaxEntriesInWindow: 1,
847 MaxEntrySize: 256,
848 })
849 keys := 1337
850
851 // when
852 for i := 0; i < keys; i++ {
853 cache.Set(fmt.Sprintf("key%d", i), []byte("value"))
854 }
855
856 // then
857 assertEqual(t, keys, cache.Len())
858
859 // and when
860 cache.Reset()
861
862 // then
863 assertEqual(t, 0, cache.Len())
864
865 // and when
866 for i := 0; i < keys; i++ {
867 cache.Set(fmt.Sprintf("key%d", i), []byte("value"))
868 }
869
870 // then
871 assertEqual(t, keys, cache.Len())
872}
873
874func TestIterateOnResetCache(t *testing.T) {
875 t.Parallel()

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…