arc cache

This commit is contained in:
royalcat 2025-01-08 00:51:11 +03:00
parent 49f1e4f345
commit c496c0269a

View file

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