From 3002f867fa468525925c8d14cd4417d871181b41 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Fri, 27 Sep 2019 14:08:27 +0200 Subject: [PATCH] ristretto: use capacity in MB --- trie/ristretto.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/trie/ristretto.go b/trie/ristretto.go index 44b3e47322..8d24d01df8 100644 --- a/trie/ristretto.go +++ b/trie/ristretto.go @@ -29,10 +29,12 @@ type RistrettoCache struct { cache *ristretto.Cache } +// NewRistrettoCache create a new ristretto cache with the given +// capacity in MB func NewRistrettoCache(capacity int) (*RistrettoCache, error) { cache, err := ristretto.NewCache(&ristretto.Config{ NumCounters: int64(capacity * 10), - MaxCost: int64(capacity), + MaxCost: int64(1000 * 1000 * capacity), BufferItems: 64, Metrics: false, KeyToHash: func(key interface{}) uint64 {