[#5] policer: Use generic LRU client

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2022-12-30 12:47:38 +03:00 committed by fyrchik
parent 55b403e0ee
commit 8f61cc1dcc
2 changed files with 4 additions and 4 deletions

View file

@ -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)
}

View file

@ -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
}