RemoveOldest removes the oldest item in the cache and returns its key and value. If the cache is empty, the empty string and nil are returned.
()
| 97 | // RemoveOldest removes the oldest item in the cache and returns its key and value. |
| 98 | // If the cache is empty, the empty string and nil are returned. |
| 99 | func (c *Cache) RemoveOldest() (key string, value interface{}) { |
| 100 | if !c.nolock { |
| 101 | c.mu.Lock() |
| 102 | defer c.mu.Unlock() |
| 103 | } |
| 104 | return c.removeOldest() |
| 105 | } |
| 106 | |
| 107 | // note: must hold c.mu |
| 108 | func (c *Cache) removeOldest() (key string, value interface{}) { |