Update updates the item only if it exists in the cache, return true if we updated the item.
(id ItemID, item Item)
| 201 | |
| 202 | // Update updates the item only if it exists in the cache, return true if we updated the item. |
| 203 | func (w *InMemoryAutoRefresh) Update(id ItemID, item Item) (ok bool) { |
| 204 | w.lock.Lock() |
| 205 | defer w.lock.Unlock() |
| 206 | ok = w.lruMap.Contains(id) |
| 207 | if ok { |
| 208 | w.lruMap.Add(id, item) |
| 209 | } |
| 210 | return ok |
| 211 | } |
| 212 | |
| 213 | // Delete deletes the item from the cache if it exists. |
| 214 | func (w *InMemoryAutoRefresh) Delete(key interface{}) { |