From c96a38eacd581161735635dd03a4963833fddac7 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Sat, 20 Apr 2024 22:22:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dttlcache=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E7=BC=BA=E5=A4=B1=E5=9B=9E=E6=94=B6=E6=95=B0=E6=8D=AE=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/utils/expires/list.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/utils/expires/list.go b/internal/utils/expires/list.go index 65ec0954..6b5b6430 100644 --- a/internal/utils/expires/list.go +++ b/internal/utils/expires/list.go @@ -55,17 +55,19 @@ func (this *List) Add(itemId uint64, expiresAt int64) { if oldExpiresAt == expiresAt { return } - delete(this.expireMap, oldExpiresAt) + delete(this.expireMap[oldExpiresAt], itemId) + if len(this.expireMap[oldExpiresAt]) == 0 { + delete(this.expireMap, oldExpiresAt) + } } expireItemMap, ok := this.expireMap[expiresAt] if ok { expireItemMap[itemId] = zero.New() } else { - expireItemMap = ItemMap{ + this.expireMap[expiresAt] = ItemMap{ itemId: zero.New(), } - this.expireMap[expiresAt] = expireItemMap } this.itemsMap[itemId] = expiresAt