修改持久化的顺序
This commit is contained in:
@@ -138,14 +138,13 @@ func (s *sGameAct) Save(actId int) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cacheGet, _ := g.Redis().Get(ctx, cacheKey)
|
cacheGet, _ := g.Redis().Get(ctx, cacheKey)
|
||||||
//最后删除key
|
|
||||||
delKey = append(delKey, cacheKey)
|
|
||||||
if uid == 0 {
|
if uid == 0 {
|
||||||
//跳过为空的用户缓存
|
//跳过为空的用户缓存
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if cacheGet.IsEmpty() {
|
if cacheGet.IsEmpty() {
|
||||||
//空数据也不巴保存
|
//空数据也不保存
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,12 +154,6 @@ func (s *sGameAct) Save(actId int) (err error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
////如果1天没有活跃,跳过
|
|
||||||
//user, _ := service.MemberUser().Info(uid)
|
|
||||||
//if user.UpdatedAt.Seconds < gtime.Now().Add(consts.ActSaveTime).Unix() {
|
|
||||||
// continue
|
|
||||||
//}
|
|
||||||
|
|
||||||
//获取数据库数据
|
//获取数据库数据
|
||||||
var data *entity.GameAct
|
var data *entity.GameAct
|
||||||
// 从数据库中查询活动信息
|
// 从数据库中查询活动信息
|
||||||
@@ -185,7 +178,8 @@ func (s *sGameAct) Save(actId int) (err error) {
|
|||||||
data.Action = actionData
|
data.Action = actionData
|
||||||
add = append(add, data)
|
add = append(add, data)
|
||||||
}
|
}
|
||||||
|
//最后删除key
|
||||||
|
delKey = append(delKey, cacheKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
//批量写入数据库
|
//批量写入数据库
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ type randMod struct {
|
|||||||
// RandomAll 按权重随机选取 N 个不重复的元素
|
// RandomAll 按权重随机选取 N 个不重复的元素
|
||||||
func (m *randMod) RandomAll(data map[int]int, n int) []int {
|
func (m *randMod) RandomAll(data map[int]int, n int) []int {
|
||||||
if n > len(data) {
|
if n > len(data) {
|
||||||
return nil
|
n = len(data)
|
||||||
}
|
}
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
// 复制权重映射,避免修改原始数据
|
// 复制权重映射,避免修改原始数据
|
||||||
|
|||||||
Reference in New Issue
Block a user