Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 257f0a6b6e |
@@ -2,7 +2,6 @@ package with
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.apinb.com/bsm-sdk/core/print"
|
"git.apinb.com/bsm-sdk/core/print"
|
||||||
@@ -11,7 +10,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func Memory(cli *bigcache.BigCache, opts *bigcache.Config) {
|
func Memory(cli *bigcache.BigCache, opts *bigcache.Config) {
|
||||||
config := bigcache.Config{
|
if opts == nil {
|
||||||
|
opts = bigcache.Config{
|
||||||
Shards: 1024,
|
Shards: 1024,
|
||||||
LifeWindow: 10 * time.Minute,
|
LifeWindow: 10 * time.Minute,
|
||||||
CleanWindow: 5 * time.Minute,
|
CleanWindow: 5 * time.Minute,
|
||||||
@@ -22,18 +22,14 @@ func Memory(cli *bigcache.BigCache, opts *bigcache.Config) {
|
|||||||
OnRemove: nil,
|
OnRemove: nil,
|
||||||
OnRemoveWithReason: nil,
|
OnRemoveWithReason: nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts != nil {
|
|
||||||
config = *opts
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
cli, err = bigcache.New(context.Background(), config)
|
cli, err = bigcache.New(context.Background(), *opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
print.Error("Memory Cache Fatal Error")
|
print.Error("Memory Cache Fatal Error")
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonBytes, _ := json.Marshal(config)
|
print.Success("[BSM - %s] Memory Cache: Shards=%d, MaxEntrySize=%d", vars.ServiceKey, opts.Shards, opts.MaxEntrySize)
|
||||||
print.Success("[BSM - %s] Memory Cache: %s", vars.ServiceKey, jsonBytes)
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user