Compare commits

...

2 Commits

Author SHA1 Message Date
ayflying
dd8c05b344 更新持久化act更新语法 2025-08-27 09:57:45 +08:00
ayflying
e781e132ed 保存计划任务调整 2025-08-22 17:50:37 +08:00
3 changed files with 15 additions and 6 deletions

View File

@@ -110,6 +110,7 @@ func (s *sGameAct) Set(uid int64, actId int, data interface{}) (err error) {
func (s *sGameAct) Saves(ctx context.Context) (err error) {
getCache, _ := pkg.Cache("redis").Get(nil, "cron:game_act")
g.Log().Debug(ctx, "开始执行游戏act数据保存了")
//如果没有执行过,设置时间戳
if getCache.Int64() > 0 {
return
@@ -122,8 +123,10 @@ func (s *sGameAct) Saves(ctx context.Context) (err error) {
ActList.Iterator(func(i interface{}) bool {
//在时间内允许执行
if gtime.Now().Before(RunTimeMax) {
g.Log().Errorf(ctx, "开始执行游戏act数据保存: act%v", i)
g.Log().Debug(ctx, "开始执行游戏act数据保存: act%v", i)
err = s.Save(ctx, i.(int))
} else {
g.Log().Errorf(ctx, "游戏act数据保存超时: act=%v", i)
}
return true
})
@@ -210,9 +213,8 @@ func (s *sGameAct) Save(ctx context.Context, actId int) (err error) {
for _, v := range update {
v.UpdatedAt = gtime.Now()
_, err2 := g.Model(Name).Where(do.GameAct{
Uid: v.Uid,
ActId: v.ActId,
UpdatedAt: v.UpdatedAt,
Uid: v.Uid,
ActId: v.ActId,
}).Data(v).Update()
if err2 != nil {
g.Log().Error(ctx, err2)

View File

@@ -56,7 +56,7 @@ func (s *sGameKv) SavesV1() (err error) {
err = tools.Redis.RedisScanV2("user:kv:*", func(keys []string) (err error) {
//判断是否超时
if gtime.Now().After(RunTimeMax) {
g.Log().Debug(ctx, "执行超时了,停止执行!")
g.Log().Error(ctx, "执行超时了,停止执行!")
return
}

View File

@@ -1,11 +1,15 @@
package utility_go
import (
"context"
"time"
"github.com/ayflying/utility_go/config"
"github.com/ayflying/utility_go/internal/boot"
_ "github.com/ayflying/utility_go/internal/logic"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gctx"
"github.com/gogf/gf/v2/os/gtimer"
)
var (
@@ -14,9 +18,12 @@ var (
)
func init() {
var err error
g.Log().Debug(ctx, "utility_go init启动完成")
// 初始化配置
var err = boot.Boot()
gtimer.SetTimeout(ctx, time.Second*5, func(ctx context.Context) {
err = boot.Boot()
})
if err != nil {
panic(err)