arc cache
This commit is contained in:
parent
49f1e4f345
commit
c496c0269a
1 changed files with 3 additions and 9 deletions
|
@ -7,8 +7,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/dgraph-io/ristretto"
|
"github.com/hashicorp/golang-lru/arc/v2"
|
||||||
lru "github.com/hashicorp/golang-lru/v2"
|
|
||||||
"github.com/royalcat/ctxio"
|
"github.com/royalcat/ctxio"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
|
@ -35,16 +34,11 @@ type block struct {
|
||||||
len int
|
len int
|
||||||
}
|
}
|
||||||
|
|
||||||
var blockCache *lru.Cache[blockIndex, block]
|
var blockCache *arc.ARCCache[blockIndex, block]
|
||||||
|
|
||||||
func ChangeBufferSize(blockCount int) {
|
|
||||||
blockCache.Resize(blockCount)
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
ristretto.NewCache(&ristretto.Config{})
|
|
||||||
var err error
|
var err error
|
||||||
blockCache, err = lru.New[blockIndex, block](defaultBlockCount)
|
blockCache, err = arc.NewARC[blockIndex, block](defaultBlockCount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue