33 lines
668 B
Go
33 lines
668 B
Go
package impl
|
|
|
|
import (
|
|
"strconv"
|
|
"strings"
|
|
|
|
"git.apinb.com/bsm-sdk/engine/cache/mem"
|
|
"git.apinb.com/bsm-sdk/engine/cache/redis"
|
|
"git.apinb.com/bsm-sdk/engine/print"
|
|
"git.apinb.com/bsm-sdk/engine/vars"
|
|
"github.com/FishGoddess/cachego"
|
|
)
|
|
|
|
var (
|
|
MemCache *cachego.Cache
|
|
RedisCache *redis.RedisClient
|
|
)
|
|
|
|
func withMemCache() {
|
|
m := mem.New()
|
|
MemCache = &m
|
|
}
|
|
|
|
func withRedisCache() {
|
|
if Configure.Cache != "" {
|
|
addrs := strings.Split(Configure.ListenOn, ":")
|
|
port, _ := strconv.Atoi(addrs[1])
|
|
RedisCache = redis.New(Configure.Cache, port)
|
|
|
|
print.Info("[Blocks Service] %s Cache: %s, DB Index: %d", vars.ServiceKey, Configure.Cache, RedisCache.DB)
|
|
}
|
|
}
|