Passed
Push — main ( 0795ea...57a23e )
by Yume
02:19 queued 01:06
created

infrastructures/ristretto.go   A

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 16
dl 0
loc 24
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A infrastructures.GetRistrettoCache 0 2 1
A infrastructures.CreateRistrettoCache 0 11 2
1
package infrastructures
2
3
import (
4
	"github.com/dgraph-io/ristretto"
5
	"github.com/memnix/memnix-rest/config"
6
)
7
8
var cache *ristretto.Cache
9
10
func CreateRistrettoCache() error {
11
	var err error
12
	if cache, err = ristretto.NewCache(&ristretto.Config{
13
		NumCounters: config.RistrettoNumCounters, // number of keys to track frequency of (10M).
14
		MaxCost:     config.RistrettoMaxCost,     // maximum cost of cache (1GB).
15
		BufferItems: config.RistrettoBufferItems, // number of keys per Get buffer.
16
	}); err != nil {
17
		return err
18
	}
19
20
	return nil
21
}
22
23
func GetRistrettoCache() *ristretto.Cache {
24
	return cache
25
}
26