Add GetPossiblyExpired()

This commit is contained in:
Dolf Schimmel 2017-02-06 00:24:14 +01:00
parent e7a9def80f
commit 249f01f691
1 changed files with 11 additions and 0 deletions

View File

@ -135,6 +135,17 @@ func (c *cache) Get(k string) (interface{}, bool) {
return item.Object, true return item.Object, true
} }
func (c *cache) GetPossiblyExpired(k string) (interface{}, bool) {
c.mu.RLock()
// "Inlining" of get and Expired
item, found := c.items[k]
c.mu.RUnlock()
if !found {
return nil, false
}
return item.Object, true
}
func (c *cache) get(k string) (interface{}, bool) { func (c *cache) get(k string) (interface{}, bool) {
item, found := c.items[k] item, found := c.items[k]
if !found { if !found {