Skip to content

Commit

Permalink
providers: use the non-locking LRU
Browse files Browse the repository at this point in the history
We only access it from a single goroutine.
  • Loading branch information
Stebalien committed Apr 13, 2019
1 parent 932162e commit df35413
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions providers/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"time"

lru "github.com/hashicorp/golang-lru"
lru "github.com/hashicorp/golang-lru/simplelru"
cid "github.com/ipfs/go-cid"
ds "github.com/ipfs/go-datastore"
autobatch "github.com/ipfs/go-datastore/autobatch"
Expand All @@ -30,7 +30,7 @@ var defaultCleanupInterval = time.Hour
type ProviderManager struct {
// all non channel fields are meant to be accessed only within
// the run method
providers *lru.Cache
providers *lru.LRU
dstore ds.Datastore

newprovs chan *addProv
Expand Down Expand Up @@ -60,7 +60,7 @@ func NewProviderManager(ctx context.Context, local peer.ID, dstore ds.Batching)
pm.getprovs = make(chan *getProv)
pm.newprovs = make(chan *addProv)
pm.dstore = autobatch.NewAutoBatching(dstore, batchBufferSize)
cache, err := lru.New(lruCacheSize)
cache, err := lru.NewLRU(lruCacheSize, nil)
if err != nil {
panic(err) //only happens if negative value is passed to lru constructor
}
Expand Down

0 comments on commit df35413

Please sign in to comment.