Delete an item from the cache. Does nothing if the key is not in the cache.
(k string)
| 903 | |
| 904 | // Delete an item from the cache. Does nothing if the key is not in the cache. |
| 905 | func (c *cache) Delete(k string) { |
| 906 | c.mu.Lock() |
| 907 | v, evicted := c.delete(k) |
| 908 | c.mu.Unlock() |
| 909 | if evicted { |
| 910 | c.onEvicted(k, v) |
| 911 | } |
| 912 | } |
| 913 | |
| 914 | func (c *cache) delete(k string) (interface{}, bool) { |
| 915 | if c.onEvicted != nil { |