(k string)
| 72 | } |
| 73 | |
| 74 | func (c *cache) get(k string) (interface{}, bool) { |
| 75 | item, found := c.items[k] |
| 76 | if !found { |
| 77 | return nil, false |
| 78 | } |
| 79 | //check item expired |
| 80 | if item.Expiration > 0 && item.Expiration < time.Now().UnixNano() { |
| 81 | return nil, false |
| 82 | } |
| 83 | return item.Object, true |
| 84 | } |
| 85 | |
| 86 | func (c *cache) Add(k string, x interface{}, d time.Duration) error { |
| 87 | c.mu.Lock() |