From 219818dc41700e18028f8f6c05cf47a0a13c6aa1 Mon Sep 17 00:00:00 2001 From: Kyle Sanderson Date: Fri, 25 Oct 2024 14:30:48 -0700 Subject: [PATCH] fix(expiration): don't add nottl items --- cache.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cache.go b/cache.go index fbfaebe..fd083f8 100644 --- a/cache.go +++ b/cache.go @@ -79,6 +79,10 @@ func New[K comparable, V any](opts ...Option[K, V]) *Cache[K, V] { // Not safe for concurrent use by multiple goroutines without additional // locking. func (c *Cache[K, V]) updateExpirations(fresh bool, elem *list.Element) { + if elem.Value.(*Item[K, V]).ttl == NoTTL { + return + } + var oldExpiresAt time.Time if !c.items.expQueue.isEmpty() {