Delete from the cache on Get if the item expired (to trigger onEvicted)

This commit is contained in:
Durand Fabrice 2018-01-03 09:44:03 -05:00
parent a3647f8e31
commit b1291d9dbe
1 changed files with 1 additions and 0 deletions

View File

@ -128,6 +128,7 @@ func (c *cache) Get(k string) (interface{}, bool) {
if item.Expiration > 0 { if item.Expiration > 0 {
if time.Now().UnixNano() > item.Expiration { if time.Now().UnixNano() > item.Expiration {
c.mu.RUnlock() c.mu.RUnlock()
c.Delete(k)
return nil, false return nil, false
} }
} }