From 799b8a2a7913a377f8fed07462342ba5f3d7142a Mon Sep 17 00:00:00 2001 From: Stone-afk <1711865140@qq.com> Date: Thu, 11 Jan 2024 22:33:40 +0800 Subject: [PATCH] feature: add lru --- memory/lru/cache.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/memory/lru/cache.go b/memory/lru/cache.go index 53cd210..2ab2883 100644 --- a/memory/lru/cache.go +++ b/memory/lru/cache.go @@ -162,13 +162,10 @@ func (c *Cache) removeElement(elem *element[entry]) { } } -func (c *Cache) remove(key string) (present bool) { +func (c *Cache) remove(key string) bool { if elem, ok := c.data[key]; ok { c.removeElement(elem) - if elem.Value.isExpired() { - return false - } - return true + return !elem.Value.isExpired() } return false }