Walk walks the old entries, if it's expired, need to remove.
(fn func(entry *cacheEntry) bool)
| 240 | |
| 241 | // Walk walks the old entries, if it's expired, need to remove. |
| 242 | func (c *LRUCache) Walk(fn func(entry *cacheEntry) bool) { |
| 243 | size := len(c.items) |
| 244 | for i := 0; i < size; i++ { |
| 245 | // get oldest entry |
| 246 | ent := c.evictList.Back() |
| 247 | if ent != nil { |
| 248 | entry := ent.Value.(*cacheEntry) |
| 249 | if fn(entry) { |
| 250 | c.removeElement(ent) |
| 251 | } else { |
| 252 | break |
| 253 | } |
| 254 | } |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | // Purge is used to completely clear the cache. |
| 259 | func (c *LRUCache) Purge(fn func(entry *cacheEntry)) { |
no test coverage detected