From a02238b012f2f303f1566f8bf351229e7409d20f Mon Sep 17 00:00:00 2001 From: siddharth ravikumar Date: Mon, 6 Jun 2022 20:08:04 -0400 Subject: cache: update `Get` Don't remove the item from the store if it is expired. --- cache/cache.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'cache') diff --git a/cache/cache.go b/cache/cache.go index 905aebe..8f29ee4 100644 --- a/cache/cache.go +++ b/cache/cache.go @@ -39,15 +39,13 @@ func (c *Cache) Set(key string, value []byte, expires time.Time) { // Get an (key,value) item from the cache store by key. // // An empty []byte will be returned when if the key does not exist or -// if the item corresponding to the key has expired. An expired -// (key,value) item will be removed from the cache store. +// if the item corresponding to the key has expired. func (c *Cache) Get(key string) []byte { if _, ok := c.store[key]; !ok { return []byte{} } // Check if the item expired. if time.Until(c.store[key].expires).Seconds() < 0 { - delete(c.store, key) return []byte{} } return c.store[key].value -- cgit v1.2.3