mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
ristretto: use capacity in MB
This commit is contained in:
parent
fa166501ad
commit
3002f867fa
1 changed files with 3 additions and 1 deletions
|
|
@ -29,10 +29,12 @@ type RistrettoCache struct {
|
||||||
cache *ristretto.Cache
|
cache *ristretto.Cache
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewRistrettoCache create a new ristretto cache with the given
|
||||||
|
// capacity in MB
|
||||||
func NewRistrettoCache(capacity int) (*RistrettoCache, error) {
|
func NewRistrettoCache(capacity int) (*RistrettoCache, error) {
|
||||||
cache, err := ristretto.NewCache(&ristretto.Config{
|
cache, err := ristretto.NewCache(&ristretto.Config{
|
||||||
NumCounters: int64(capacity * 10),
|
NumCounters: int64(capacity * 10),
|
||||||
MaxCost: int64(capacity),
|
MaxCost: int64(1000 * 1000 * capacity),
|
||||||
BufferItems: 64,
|
BufferItems: 64,
|
||||||
Metrics: false,
|
Metrics: false,
|
||||||
KeyToHash: func(key interface{}) uint64 {
|
KeyToHash: func(key interface{}) uint64 {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue