mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 11:04:02 +03:00
Correct initialization of antireplay cache
This commit is contained in:
+4
-7
@@ -1,9 +1,6 @@
|
|||||||
package antireplay
|
package antireplay
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/allegro/bigcache"
|
"github.com/allegro/bigcache"
|
||||||
|
|
||||||
"github.com/9seconds/mtg/config"
|
"github.com/9seconds/mtg/config"
|
||||||
@@ -20,15 +17,15 @@ func Has(data []byte) bool {
|
|||||||
return err == nil
|
return err == nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Init() error {
|
func Init() {
|
||||||
c, err := bigcache.NewBigCache(bigcache.Config{
|
c, err := bigcache.NewBigCache(bigcache.Config{
|
||||||
Shards: 1024,
|
Shards: 1024,
|
||||||
LifeWindow: config.C.AntiReplay.EvictionTime,
|
LifeWindow: config.C.AntiReplay.EvictionTime,
|
||||||
Hasher: hasher{},
|
Hasher: hasher{},
|
||||||
HardMaxCacheSize: config.C.AntiReplay.MaxSize,
|
HardMaxCacheSize: config.C.AntiReplay.MaxSize,
|
||||||
})
|
})
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
cache = c
|
cache = c
|
||||||
err = fmt.Errorf("qqq: %w", errors.New("tt"))
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -60,9 +60,7 @@ func Proxy() error {
|
|||||||
|
|
||||||
PrintJSONStdout(config.GetURLs())
|
PrintJSONStdout(config.GetURLs())
|
||||||
|
|
||||||
if err := antireplay.Init(); err != nil {
|
antireplay.Init()
|
||||||
Fatal(err)
|
|
||||||
}
|
|
||||||
if err := stats.Init(ctx); err != nil {
|
if err := stats.Init(ctx); err != nil {
|
||||||
Fatal(err)
|
Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user