Revert "[#866] Use TTL for blobovnicza tree cache"

This reverts commit d9cbb16bd3.

Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
Anton Nikiforov 2024-03-01 19:29:33 +03:00
parent 46a04463b2
commit ae5bb87e70
10 changed files with 17 additions and 55 deletions

View file

@ -1,11 +1,10 @@
package blobovniczatree
import (
"fmt"
"sync"
"time"
utilSync "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/sync"
"github.com/hashicorp/golang-lru/v2/expirable"
"github.com/hashicorp/golang-lru/v2/simplelru"
)
@ -23,10 +22,14 @@ type dbCache struct {
dbManager *dbManager
}
func newDBCache(size int, ttl time.Duration, dbManager *dbManager) *dbCache {
cache := expirable.NewLRU(size, func(_ string, evictedDB *sharedDB) {
func newDBCache(size int, dbManager *dbManager) *dbCache {
cache, err := simplelru.NewLRU(size, func(_ string, evictedDB *sharedDB) {
evictedDB.Close()
}, ttl)
})
if err != nil {
// occurs only if the size is not positive
panic(fmt.Errorf("could not create LRU cache of size %d: %w", size, err))
}
return &dbCache{
cacheGuard: &sync.RWMutex{},
cache: cache,