25 lines
658 B
Go
25 lines
658 B
Go
package with
|
|
|
|
import (
|
|
"time"
|
|
|
|
"git.apinb.com/bsm-sdk/core/conf"
|
|
"git.apinb.com/bsm-sdk/core/printer"
|
|
"git.apinb.com/bsm-sdk/core/vars"
|
|
cache "github.com/patrickmn/go-cache"
|
|
)
|
|
|
|
func Memory(opts *conf.MemoryCacheConf) *cache.Cache {
|
|
if opts == nil {
|
|
opts = &conf.MemoryCacheConf{
|
|
DefaultExpiration: 60 * 60, // 1 hour
|
|
CleanupInterval: 24 * 60 * 60, // 1 day
|
|
}
|
|
}
|
|
|
|
printer.Success("[BSM - %s] Memory Cache: DefaultExpiration=%d, CleanupInterval=%d", vars.ServiceKey, opts.DefaultExpiration, opts.CleanupInterval)
|
|
|
|
return cache.New(time.Duration(opts.DefaultExpiration)*time.Second, time.Duration(opts.CleanupInterval)*time.Second)
|
|
|
|
}
|