From 8f61cc1dccc92fcef05459dee3efacf3c79a61f6 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 30 Dec 2022 12:47:38 +0300 Subject: [PATCH] [#5] policer: Use generic LRU client Signed-off-by: Evgenii Stratonikov --- pkg/services/policer/policer.go | 6 +++--- pkg/services/policer/process.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/services/policer/policer.go b/pkg/services/policer/policer.go index 2245ab792..e556e7959 100644 --- a/pkg/services/policer/policer.go +++ b/pkg/services/policer/policer.go @@ -12,7 +12,7 @@ import ( "github.com/TrueCloudLab/frostfs-node/pkg/services/replicator" "github.com/TrueCloudLab/frostfs-node/pkg/util/logger" oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id" - lru "github.com/hashicorp/golang-lru" + lru "github.com/hashicorp/golang-lru/v2" "github.com/panjf2000/ants/v2" "go.uber.org/zap" ) @@ -53,7 +53,7 @@ func (oiw *objectsInWork) add(addr oid.Address) { type Policer struct { *cfg - cache *lru.Cache + cache *lru.Cache[oid.Address, time.Time] objsInWork *objectsInWork } @@ -115,7 +115,7 @@ func New(opts ...Option) *Policer { c.log = &logger.Logger{Logger: c.log.With(zap.String("component", "Object Policer"))} - cache, err := lru.New(int(c.cacheSize)) + cache, err := lru.New[oid.Address, time.Time](int(c.cacheSize)) if err != nil { panic(err) } diff --git a/pkg/services/policer/process.go b/pkg/services/policer/process.go index 042bc20c9..eeb9fe491 100644 --- a/pkg/services/policer/process.go +++ b/pkg/services/policer/process.go @@ -56,7 +56,7 @@ func (p *Policer) shardPolicyWorker(ctx context.Context) { err = p.taskPool.Submit(func() { v, ok := p.cache.Get(addr.Address) - if ok && time.Since(v.(time.Time)) < p.evictDuration { + if ok && time.Since(v) < p.evictDuration { return }