From c496c0269afde549c38d1add48752b83ba88fe82 Mon Sep 17 00:00:00 2001 From: royalcat Date: Wed, 8 Jan 2025 00:51:11 +0300 Subject: [PATCH] arc cache --- src/vfs/archive_cache.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/vfs/archive_cache.go b/src/vfs/archive_cache.go index a707ef6..fd3bde0 100644 --- a/src/vfs/archive_cache.go +++ b/src/vfs/archive_cache.go @@ -7,8 +7,7 @@ import ( "io" "sync" - "github.com/dgraph-io/ristretto" - lru "github.com/hashicorp/golang-lru/v2" + "github.com/hashicorp/golang-lru/arc/v2" "github.com/royalcat/ctxio" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" @@ -35,16 +34,11 @@ type block struct { len int } -var blockCache *lru.Cache[blockIndex, block] - -func ChangeBufferSize(blockCount int) { - blockCache.Resize(blockCount) -} +var blockCache *arc.ARCCache[blockIndex, block] func init() { - ristretto.NewCache(&ristretto.Config{}) var err error - blockCache, err = lru.New[blockIndex, block](defaultBlockCount) + blockCache, err = arc.NewARC[blockIndex, block](defaultBlockCount) if err != nil { panic(err) }