From 6c4ea694f9d381a4e55958fb7c91fcbca519c3e1 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Wed, 15 Nov 2023 15:17:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AE=A1=E6=95=B0=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/utils/counters/counter.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/internal/utils/counters/counter.go b/internal/utils/counters/counter.go index 52a7515..a711f2e 100644 --- a/internal/utils/counters/counter.go +++ b/internal/utils/counters/counter.go @@ -66,13 +66,10 @@ func (this *Counter) Increase(key uint64, lifeSeconds int) uint64 { var index = int(key % this.countMaps) this.locker.RLock(index) var item = this.itemMaps[index][key] - var l = len(this.itemMaps[index]) this.locker.RUnlock(index) - if item == nil { // no need to care about duplication - if l > maxItemsPerGroup { - return 1 - } - + if item == nil { + // no need to care about duplication + // always insert new item even when itemMap is full item = NewItem(lifeSeconds) this.locker.Lock(index) this.itemMaps[index][key] = item