Total Lines | 24 |
Duplicated Lines | 0 % |
Changes | 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 |