Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f70f8d94db | |||
| 257f0a6b6e | |||
| 5e25e8eccc | |||
| 4f584726d6 | |||
| b9d144353e |
14
cache/mem/mem.go
vendored
14
cache/mem/mem.go
vendored
@@ -1,14 +0,0 @@
|
||||
package mem
|
||||
|
||||
import (
|
||||
"git.apinb.com/bsm-sdk/core/vars"
|
||||
"github.com/FishGoddess/cachego"
|
||||
)
|
||||
|
||||
func New() cachego.Cache {
|
||||
return cachego.NewCache(
|
||||
cachego.WithGC(vars.MemGcDuration),
|
||||
cachego.WithShardings(vars.MemShardings),
|
||||
cachego.WithLFU(vars.MemLRUMaxNumber),
|
||||
)
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
|
||||
func Etcd(cfg *conf.EtcdConf, cli *clientv3.Client) {
|
||||
if cfg == nil || len(cfg.Endpoints) == 0 {
|
||||
panic("Etcd endpoints is Empty!")
|
||||
return
|
||||
}
|
||||
|
||||
etcdCfg := clientv3.Config{
|
||||
|
||||
35
with/memory.go
Normal file
35
with/memory.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package with
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/print"
|
||||
"git.apinb.com/bsm-sdk/core/vars"
|
||||
"github.com/allegro/bigcache/v3"
|
||||
)
|
||||
|
||||
func Memory(cli *bigcache.BigCache, opts *bigcache.Config) {
|
||||
if opts == nil {
|
||||
opts = &bigcache.Config{
|
||||
Shards: 1024,
|
||||
LifeWindow: 10 * time.Minute,
|
||||
CleanWindow: 5 * time.Minute,
|
||||
MaxEntriesInWindow: 1000 * 10 * 60,
|
||||
MaxEntrySize: 500,
|
||||
Verbose: true,
|
||||
HardMaxCacheSize: 8192,
|
||||
OnRemove: nil,
|
||||
OnRemoveWithReason: nil,
|
||||
}
|
||||
}
|
||||
|
||||
var err error
|
||||
cli, err = bigcache.New(context.Background(), *opts)
|
||||
if err != nil {
|
||||
print.Error("Memory Cache Fatal Error")
|
||||
panic(err)
|
||||
}
|
||||
|
||||
print.Success("[BSM - %s] Memory Cache: Shards=%d, MaxEntrySize=%d", vars.ServiceKey, opts.Shards, opts.MaxEntrySize)
|
||||
}
|
||||
Reference in New Issue
Block a user