MCPcopy Create free account
hub / github.com/patrickmn/go-cache / set

Method set

cache.go:70–82  ·  view source on GitHub ↗
(k string, x interface{}, d time.Duration)

Source from the content-addressed store, hash-verified

68}
69
70func (c *cache) set(k string, x interface{}, d time.Duration) {
71 var e int64
72 if d == DefaultExpiration {
73 d = c.defaultExpiration
74 }
75 if d > 0 {
76 e = time.Now().Add(d).UnixNano()
77 }
78 c.items[k] = Item{
79 Object: x,
80 Expiration: e,
81 }
82}
83
84// Add an item to the cache, replacing any existing item, using the default
85// expiration.

Callers 4

AddMethod · 0.95
ReplaceMethod · 0.95

Calls 1

AddMethod · 0.45

Tested by 2