提交 947200aa authored 作者: mooncake's avatar mooncake

update

上级 910f2321
......@@ -25,6 +25,7 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/app"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
_ "gitlab.wanzhuangkj.com/tush/xpkg/xcron"
_ "gitlab.wanzhuangkj.com/tush/xpkg/xutils/redsyncutils"
)
func init() {
......
......@@ -7,6 +7,8 @@ import (
"github.com/go-redsync/redsync/v4"
"github.com/go-redsync/redsync/v4/redis/goredis/v9"
"github.com/redis/go-redis/v9"
"gitlab.wanzhuangkj.com/tush/xpkg/database"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
ctxutils "gitlab.wanzhuangkj.com/tush/xpkg/xutils/ctxutils"
......@@ -16,7 +18,13 @@ var (
redSync *redsync.Redsync
)
func Init(redisCli *redis.Client) {
func init() {
eventbus.Eb.Subscribe(eventbus.TopicCacheInitFinish, func(ctx context.Context) {
initialize(database.GetRedisCli())
})
}
func initialize(redisCli *redis.Client) {
pool := goredis.NewPool(redisCli)
redSync = redsync.New(pool)
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论