Skip to content

Commit

Permalink
临时修复代码
Browse files Browse the repository at this point in the history
  • Loading branch information
xiyoo0812 committed Nov 9, 2023
1 parent b4be94a commit 4f8d695
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion script/store/redis_mgr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ end
function RedisMgr:execute(db_id, cmd, ...)
local redisdb = self:get_db(db_id)
if redisdb then
log_debug("[RedisMgr][execute]: cmd {}, args: {}", cmd, {...})
local res = tpack(redisdb:execute(cmd, ...))
if not res[1] then
log_err("[RedisMgr][execute] execute {} ({}) failed, because: {}", cmd, {...}, res[2])
return res[1] and SUCCESS or REDIS_FAILED, res[2]
end
log_debug("[RedisMgr][execute]: cmd {}, args: {}", cmd, {...})
return SUCCESS, tunpack(res, 2)
end
return REDIS_FAILED, "redis db not exist"
Expand Down
10 changes: 6 additions & 4 deletions server/cache/cache_mgr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ end

--需要更新的表
function CacheMgr:save_doc(document)
self.save_documents[document] = true
self.save_documents[document] = quanta.frame
end

function CacheMgr:build_fields(field)
Expand All @@ -112,13 +112,15 @@ function CacheMgr:on_frame()
--保存数据
if next(self.save_documents) then
local count = 0
for document in pairs(self.save_documents) do
for doc, frame in pairs(self.save_documents) do
channel:push(function()
local ok, code = document:update()
local ok, code = doc:update()
if qfailed(code, ok) then
return false
end
self.save_documents[document] = nil
if frame == self.save_documents[doc] then
self.save_documents[doc] = nil
end
return true, code
end)
count = count + 1
Expand Down
2 changes: 1 addition & 1 deletion server/cache/document.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ end

--保存数据库
function Document:update()
self.flushing = false
local channel = makechan("doc update")
--清理缓存
channel:push(function()
self.flushing = false
local rcode, rres = redis_mgr:execute(MAIN_DBID, "DEL", self.hotkey)
if qfailed(rcode) then
log_err("[Document][update] del failed: {}=> hotkey: {}", rres, self.hotkey)
Expand Down

0 comments on commit 4f8d695

Please sign in to comment.