Skip to content

Commit

Permalink
fix: 修复编辑审核通过后,词条各统计数据缓存重新置0的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Liusiyuan-git committed Jan 21, 2023
1 parent a7d9edd commit 0af422c
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 32 deletions.
2 changes: 1 addition & 1 deletion app/creation/service/internal/data/article.go
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,7 @@ func (r *articleRepo) CreateArticleCache(ctx context.Context, id, auth int32, uu
creationUserVisitor := "creation_user_visitor_" + uuid
keys := []string{articleStatistic, article, articleHot, leaderboard, userArticleList, userArticleListVisitor, creationUser, creationUserVisitor}
values := []interface{}{uuid, auth, id, ids + "%" + uuid, mode, ids + "%" + uuid + "%article"}
_, err := r.data.redisCli.EvalSha(ctx, "03c2dc8c6fdf154a7e6387dc4b0ba296a499c7b6", keys, values...).Result()
_, err := r.data.redisCli.EvalSha(ctx, "f1dcbca8b2c0cebc82fb4f1ab03fe38a1e724806", keys, values...).Result()
if err != nil {
return errors.Wrapf(err, fmt.Sprintf("fail to create(update) article cache: uuid(%s), id(%v)", uuid, id))
}
Expand Down
2 changes: 1 addition & 1 deletion app/creation/service/internal/data/column.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ func (r *columnRepo) CreateColumnCache(ctx context.Context, id, auth int32, uuid
creationUserVisitor := "creation_user_visitor_" + uuid
keys := []string{columnStatistic, column, columnHot, leaderboard, userColumnList, userColumnListVisitor, creationUser, creationUserVisitor}
values := []interface{}{uuid, auth, id, ids + "%" + uuid, mode, ids + "%" + uuid + "%column"}
_, err := r.data.redisCli.EvalSha(ctx, "89db8d00c64b369f84452619f87054c2f90a5445", keys, values...).Result()
_, err := r.data.redisCli.EvalSha(ctx, "bbdbb07ceeb4311feba0a520473629ff010a173b", keys, values...).Result()
if err != nil {
return errors.Wrapf(err, fmt.Sprintf("fail to create(update) column cache: uuid(%s), id(%v)", uuid, id))
}
Expand Down
2 changes: 1 addition & 1 deletion app/creation/service/internal/data/creation.go
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ func (r *creationRepo) CreateCollectionsCache(ctx context.Context, id, auth int3
collectionsStatistic := "collections_" + ids
keys := []string{collectionsStatistic, userCollectionsList, userCollectionsListVisitor, creationUser, creationUserVisitor, userCollectionsListAll}
values := []interface{}{uuid, auth, id, ids, mode}
_, err := r.data.redisCli.EvalSha(ctx, "38375bb0cadfcd92739dba054e387f7985a6c331", keys, values...).Result()
_, err := r.data.redisCli.EvalSha(ctx, "9039a6379902063ce62ed14d7bbfa269ae219298", keys, values...).Result()
if err != nil {
return errors.Wrapf(err, fmt.Sprintf("fail to create(update) collections cache: uuid(%s), id(%v)", uuid, id))
}
Expand Down
2 changes: 1 addition & 1 deletion app/creation/service/internal/data/talk.go
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,7 @@ func (r *talkRepo) CreateTalkCache(ctx context.Context, id, auth int32, uuid, mo
creationUserVisitor := "creation_user_visitor_" + uuid
keys := []string{talkStatistic, talk, talkHot, leaderboard, userTalkList, userTalkListVisitor, creationUser, creationUserVisitor}
values := []interface{}{uuid, auth, id, ids + "%" + uuid, mode, ids + "%" + uuid + "%talk"}
_, err := r.data.redisCli.EvalSha(ctx, "eb5d94a2a972340b5ac93769524a51911f9c032f", keys, values...).Result()
_, err := r.data.redisCli.EvalSha(ctx, "069bd468f5f94ae744658c878046caab15711709", keys, values...).Result()
if err != nil {
return errors.Wrapf(err, fmt.Sprintf("fail to create(update) talk cache: uuid(%s), id(%v)", uuid, id))
}
Expand Down
64 changes: 36 additions & 28 deletions app/creation/service/internal/tool/lua/lua.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,16 @@ var (
local leaderboardExist = redis.call("EXISTS", leaderboard)
local userArticleListVisitorExist = redis.call("EXISTS", userArticleListVisitor)
local creationUserVisitorExist = redis.call("EXISTS", creationUserVisitor)
redis.call("HSETNX", articleStatistic, "uuid", uuid)
redis.call("HSETNX", articleStatistic, "agree", 0)
redis.call("HSETNX", articleStatistic, "collect", 0)
redis.call("HSETNX", articleStatistic, "view", 0)
redis.call("HSETNX", articleStatistic, "comment", 0)
redis.call("HSETNX", articleStatistic, "auth", auth)
redis.call("EXPIRE", articleStatistic, 1800)
if mode == "create" then
redis.call("HSETNX", articleStatistic, "uuid", uuid)
redis.call("HSETNX", articleStatistic, "agree", 0)
redis.call("HSETNX", articleStatistic, "collect", 0)
redis.call("HSETNX", articleStatistic, "view", 0)
redis.call("HSETNX", articleStatistic, "comment", 0)
redis.call("HSETNX", articleStatistic, "auth", auth)
redis.call("EXPIRE", articleStatistic, 1800)
end
if userArticleListExist == 1 then
redis.call("ZADD", userArticleList, id, member)
Expand Down Expand Up @@ -385,13 +387,15 @@ var (
local userColumnListVisitorExist = redis.call("EXISTS", userColumnListVisitor)
local creationUserVisitorExist = redis.call("EXISTS", creationUserVisitor)
redis.call("HSETNX", columnStatistic, "uuid", uuid)
redis.call("HSETNX", columnStatistic, "agree", 0)
redis.call("HSETNX", columnStatistic, "collect", 0)
redis.call("HSETNX", columnStatistic, "view", 0)
redis.call("HSETNX", columnStatistic, "comment", 0)
redis.call("HSETNX", columnStatistic, "auth", auth)
redis.call("EXPIRE", columnStatistic, 1800)
if mode == "create" then
redis.call("HSETNX", columnStatistic, "uuid", uuid)
redis.call("HSETNX", columnStatistic, "agree", 0)
redis.call("HSETNX", columnStatistic, "collect", 0)
redis.call("HSETNX", columnStatistic, "view", 0)
redis.call("HSETNX", columnStatistic, "comment", 0)
redis.call("HSETNX", columnStatistic, "auth", auth)
redis.call("EXPIRE", columnStatistic, 1800)
end
if userColumnListExist == 1 then
redis.call("ZADD", userColumnList, id, member)
Expand Down Expand Up @@ -764,12 +768,14 @@ var (
local creationUserVisitorExist = redis.call("EXISTS", creationUserVisitor)
local userCollectionsListAllExist = redis.call("EXISTS", userCollectionsListAll)
redis.call("HSETNX", collectionsStatistic, "uuid", uuid)
redis.call("HSETNX", collectionsStatistic, "auth", auth)
redis.call("HSETNX", collectionsStatistic, "article", 0)
redis.call("HSETNX", collectionsStatistic, "column", 0)
redis.call("HSETNX", collectionsStatistic, "talk", 0)
redis.call("EXPIRE", collectionsStatistic, 1800)
if mode == "create" then
redis.call("HSETNX", collectionsStatistic, "uuid", uuid)
redis.call("HSETNX", collectionsStatistic, "auth", auth)
redis.call("HSETNX", collectionsStatistic, "article", 0)
redis.call("HSETNX", collectionsStatistic, "column", 0)
redis.call("HSETNX", collectionsStatistic, "talk", 0)
redis.call("EXPIRE", collectionsStatistic, 1800)
end
if userCollectionsListExist == 1 then
redis.call("ZADD", userCollectionsList, id, ids)
Expand Down Expand Up @@ -918,13 +924,15 @@ var (
local userTalkListVisitorExist = redis.call("EXISTS", userTalkListVisitor)
local creationUserVisitorExist = redis.call("EXISTS", creationUserVisitor)
redis.call("HSETNX", talkStatistic, "uuid", uuid)
redis.call("HSETNX", talkStatistic, "agree", 0)
redis.call("HSETNX", talkStatistic, "collect", 0)
redis.call("HSETNX", talkStatistic, "view", 0)
redis.call("HSETNX", talkStatistic, "comment", 0)
redis.call("HSETNX", talkStatistic, "auth", auth)
redis.call("EXPIRE", talkStatistic, 1800)
if mode == "create" then
redis.call("HSETNX", talkStatistic, "uuid", uuid)
redis.call("HSETNX", talkStatistic, "agree", 0)
redis.call("HSETNX", talkStatistic, "collect", 0)
redis.call("HSETNX", talkStatistic, "view", 0)
redis.call("HSETNX", talkStatistic, "comment", 0)
redis.call("HSETNX", talkStatistic, "auth", auth)
redis.call("EXPIRE", talkStatistic, 1800)
end
if userTalkListExist == 1 then
redis.call("ZADD", userTalkList, id, member)
Expand Down

0 comments on commit 0af422c

Please sign in to comment.