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

Function TestNewLRUExpireCache1

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

Source from the content-addressed store, hash-verified

8)
9
10func TestNewLRUExpireCache1(t *testing.T) {
11 contractLookupCache := NewLRUExpireCache(3)
12 forceLiveLookupTTL := 1 * time.Second
13 contractLookupCache.Add("key1", true, forceLiveLookupTTL)
14 v1, gotIt := contractLookupCache.Get("key1")
15 assert.True(t, gotIt)
16 assert.NotNil(t, v1)
17
18 time.Sleep(1 * time.Second)
19 v1, gotIt = contractLookupCache.Get("key1")
20 assert.False(t, gotIt)
21 assert.Nil(t, v1)
22}
23
24func TestNewLRUExpireCache2(t *testing.T) {
25 contractLookupCache := NewLRUExpireCache(3)

Callers

nothing calls this directly

Calls 4

AddMethod · 0.95
GetMethod · 0.95
NewLRUExpireCacheFunction · 0.85
SleepMethod · 0.80

Tested by

no test coverage detected