FILE / ScuroNeko/mtg

antireplay/init.go

Исходный файл и его история в репозитории.
FILE 22905b2a25c3cad48f1a97a67b33986b1dc61697
Files
mtg/antireplay/init.go
T

43 lines
764 B
Go

package antireplay
import (
"sync"
"github.com/9seconds/mtg/config"
"github.com/allegro/bigcache"
)
var (
Cache *cache
initOnce sync.Once
)
func Init() {
initOnce.Do(func() {
c1, err := bigcache.NewBigCache(bigcache.Config{
Shards: 1024,
LifeWindow: config.C.AntiReplayEvictionTime,
Hasher: hasher{},
HardMaxCacheSize: config.C.AntiReplayMaxSize,
})
if err != nil {
panic(err)
}
c2, err := bigcache.NewBigCache(bigcache.Config{
Shards: 1024,
LifeWindow: config.C.AntiReplayEvictionTime,
Hasher: hasher{},
HardMaxCacheSize: config.C.AntiReplayMaxSize,
})
if err != nil {
panic(err)
}
Cache = &cache{
obfuscated2: c1,
tls: c2,
}
})
}