feat: import services and standardize Go 1.26.5
This commit is contained in:
32
apps/ec/delivery/internal/impl/cache.go
Normal file
32
apps/ec/delivery/internal/impl/cache.go
Normal file
@@ -0,0 +1,32 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user