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

infrastructures.GetRistrettoCache   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
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