MCPcopy Create free account
hub / github.com/CPChain/chain / TestNewLRUExpireCache2

Function TestNewLRUExpireCache2

commons/cache/lru_expire_cache_test.go:24–35  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22}
23
24func TestNewLRUExpireCache2(t *testing.T) {
25 contractLookupCache := NewLRUExpireCache(3)
26 forceLiveLookupTTL := 1 * time.Second
27 contractLookupCache.Add("key1", true, forceLiveLookupTTL)
28 contractLookupCache.Add("key2", true, forceLiveLookupTTL)
29 contractLookupCache.Add("key3", true, forceLiveLookupTTL)
30 contractLookupCache.Add("key4", true, forceLiveLookupTTL)
31 v1, gotIt := contractLookupCache.Get("key1")
32 assert.False(t, gotIt)
33 assert.Nil(t, v1)
34 assert.Equal(t, 3, len(contractLookupCache.Keys()))
35}

Callers

nothing calls this directly

Calls 5

AddMethod · 0.95
GetMethod · 0.95
KeysMethod · 0.95
NewLRUExpireCacheFunction · 0.85
EqualMethod · 0.65

Tested by

no test coverage detected