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