From eebd44da9dd95754da5457950ddd63119a94dc66 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Mon, 22 Feb 2021 12:00:32 +0800 Subject: [PATCH] fix #1341 --- lualib/skynet/db/redis.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lualib/skynet/db/redis.lua b/lualib/skynet/db/redis.lua index 9b394489..b1def3fd 100644 --- a/lualib/skynet/db/redis.lua +++ b/lualib/skynet/db/redis.lua @@ -96,7 +96,17 @@ local count_cache = make_cache(function(t,k) return s end) +local command_np_cache = make_cache(function(t, cmd) + local s = "*1" .. command_cache[cmd] .. "\r\n" + t[cmd] = s + return s + end) + local function compose_message(cmd, msg) + if msg == nil then + return command_np_cache[cmd] + end + local t = type(msg) local lines = {} @@ -160,7 +170,9 @@ end setmetatable(command, { __index = function(t,k) local cmd = string.upper(k) local f = function (self, v, ...) - if type(v) == "table" then + if v == nil then + return self[1]:request(compose_message(cmd), read_response) + elseif type(v) == "table" then return self[1]:request(compose_message(cmd, v), read_response) else return self[1]:request(compose_message(cmd, table.pack(v, ...)), read_response)