Conditions | 3 |
Total Lines | 13 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | // Package weakcache implements Weak Cache, eviction of entries are controlled by GC |
||
29 | func (c *WeakCache) Get(key string) (value string, ok bool) { |
||
30 | v, ok := c.Load(key) |
||
31 | if ok { |
||
32 | ref := v.(*weakref.WeakRef) |
||
33 | if ref.IsAlive() { |
||
34 | metrics.Hits.Inc() |
||
35 | return ref.GetTarget().(string), true |
||
36 | } |
||
37 | metrics.Deletes.Inc() |
||
38 | c.Delete(key) |
||
39 | } |
||
40 | metrics.Miss.Inc() |
||
41 | return "", false |
||
42 | } |
||
50 |