From 249f01f69118e4d7d42c9163b41653dd370bedc0 Mon Sep 17 00:00:00 2001 From: Dolf Schimmel Date: Mon, 6 Feb 2017 00:24:14 +0100 Subject: [PATCH] Add GetPossiblyExpired() --- cache.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cache.go b/cache.go index 70e4dad..5de5e54 100644 --- a/cache.go +++ b/cache.go @@ -135,6 +135,17 @@ func (c *cache) Get(k string) (interface{}, bool) { 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) { item, found := c.items[k] if !found {