mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-09-01 16:01:55 +03:00
Use fastcache instead of ristretto
This commit is contained in:
+2
-16
@@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user