summaryrefslogtreecommitdiffstats
path: root/cache/cache.go
diff options
context:
space:
mode:
authorsiddharth ravikumar <s@ricketyspace.net>2022-06-06 20:08:04 -0400
committersiddharth ravikumar <s@ricketyspace.net>2022-06-06 20:08:04 -0400
commita02238b012f2f303f1566f8bf351229e7409d20f (patch)
tree815818ee5a0c117252b63f082fdf4a5b20c865b6 /cache/cache.go
parentf739cf38b8bf1e8d252dedaf5f7055df4ed3f8e7 (diff)
cache: update `Get`
Don't remove the item from the store if it is expired.
Diffstat (limited to 'cache/cache.go')
-rw-r--r--cache/cache.go4
1 files changed, 1 insertions, 3 deletions
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