7
7
"sync/atomic"
8
8
"time"
9
9
10
- lru "github.com/hashicorp/golang-lru"
10
+ lru "github.com/hashicorp/golang-lru/v2 "
11
11
"github.com/ipfs/go-datastore"
12
12
"github.com/ipfs/go-datastore/namespace"
13
13
logging "github.com/ipfs/go-log/v2"
@@ -31,7 +31,7 @@ type Store[H header.Header[H]] struct {
31
31
// underlying KV store
32
32
ds datastore.Batching
33
33
// adaptive replacement cache of headers
34
- cache * lru.ARCCache
34
+ cache * lru.TwoQueueCache [ string , H ]
35
35
// metrics collection instance
36
36
metrics * metrics
37
37
@@ -89,7 +89,7 @@ func newStore[H header.Header[H]](ds datastore.Batching, opts ...Option) (*Store
89
89
return nil , fmt .Errorf ("header/store: store creation failed: %w" , err )
90
90
}
91
91
92
- cache , err := lru .NewARC (params .StoreCacheSize )
92
+ cache , err := lru.New2Q [ string , H ] (params .StoreCacheSize )
93
93
if err != nil {
94
94
return nil , fmt .Errorf ("failed to create index cache: %w" , err )
95
95
}
@@ -198,7 +198,7 @@ func (s *Store[H]) Head(ctx context.Context, _ ...header.HeadOption[H]) (H, erro
198
198
func (s * Store [H ]) Get (ctx context.Context , hash header.Hash ) (H , error ) {
199
199
var zero H
200
200
if v , ok := s .cache .Get (hash .String ()); ok {
201
- return v .( H ) , nil
201
+ return v , nil
202
202
}
203
203
// check if the requested header is not yet written on disk
204
204
if h := s .pending .Get (hash ); ! h .IsZero () {
0 commit comments