Add inserts an item into the cache.
(obj interface{})
| 121 | |
| 122 | // Add inserts an item into the cache. |
| 123 | func (c *cache) Add(obj interface{}) error { |
| 124 | key, err := c.keyFunc(obj) |
| 125 | if err != nil { |
| 126 | return KeyError{obj, err} |
| 127 | } |
| 128 | c.cacheStorage.Add(key, obj) |
| 129 | return nil |
| 130 | } |
| 131 | |
| 132 | // Update sets an item in the cache to its updated state. |
| 133 | func (c *cache) Update(obj interface{}) error { |