From 2accda91693919909d95aa6a4be5a5b5fe51bb40 Mon Sep 17 00:00:00 2001 From: Dzianis Lapanik Date: Wed, 25 May 2022 20:07:05 +0300 Subject: [PATCH] attempt #2. fix for Time zero value --- cache.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cache.go b/cache.go index 1d5f627..4f1f801 100644 --- a/cache.go +++ b/cache.go @@ -22,7 +22,7 @@ func (c *Cache) Get(key string) (string, bool) { return "", false } - if value.deadline.Before(time.Now()) { + if !value.deadline.IsZero() && value.deadline.Before(time.Now()) { delete(c.data, key) return "", false } @@ -42,7 +42,7 @@ func (c *Cache) Keys() []string { now := time.Now() for key, value := range c.data { - if value.deadline.Before(now) { + if !value.deadline.IsZero() && value.deadline.Before(now) { delete(c.data, key) } else { keys = append(keys, key)