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

Method Add

commons/cache/lru_expire_cache.go:25–29  ·  view source on GitHub ↗

add new element

(key interface{}, value interface{}, ttl time.Duration)

Source from the content-addressed store, hash-verified

23
24// add new element
25func (c *LRUExpireCache) Add(key interface{}, value interface{}, ttl time.Duration) {
26 c.lock.Lock()
27 defer c.lock.Unlock()
28 c.cache.Add(key, &cacheEntry{value, c.clock.Now().Add(ttl)})
29}
30
31// get unexpired element from lru cache
32func (c *LRUExpireCache) Get(key interface{}) (interface{}, bool) {

Callers 2

TestNewLRUExpireCache1Function · 0.95
TestNewLRUExpireCache2Function · 0.95

Calls 4

LockMethod · 0.80
UnlockMethod · 0.80
AddMethod · 0.65
NowMethod · 0.65

Tested by 2

TestNewLRUExpireCache1Function · 0.76
TestNewLRUExpireCache2Function · 0.76