Evict cache entry if it's found to be stale when we call Get

This commit is contained in:
Neil Alexander 2022-03-01 15:32:19 +00:00
parent eb9e90a30c
commit 2e2d40b7ba
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -153,6 +153,7 @@ func (c *InMemoryLRUCachePartition) Get(key string) (value interface{}, ok bool)
return nil, false
}
if c.maxAge > 0 && time.Since(entry.created) > c.maxAge {
c.lru.Remove(key)
return nil, false
}
return entry.value, true