Use fastcache instead of ristretto

This commit is contained in:
9seconds
2019-11-11 16:05:19 +03:00
parent 6732e80d06
commit ae479adeaa
5 changed files with 28 additions and 35 deletions
+2 -16
View File
@@ -1,10 +1,9 @@
package antireplay
import (
"math"
"sync"
"github.com/dgraph-io/ristretto"
"github.com/VictoriaMetrics/fastcache"
"mtg/config"
)
@@ -16,19 +15,6 @@ var (
func Init() {
initOnce.Do(func() {
cost := float64(config.C.AntiReplayMaxSize) / 32.0
cost = math.Ceil(cost)
c, err := ristretto.NewCache(&ristretto.Config{
NumCounters: int64(cost) * 10,
MaxCost: config.C.AntiReplayMaxSize,
BufferItems: 64,
Metrics: false,
})
if err != nil {
panic(err)
}
Cache.data = c
Cache.data = fastcache.New(config.C.AntiReplayMaxSize)
})
}