mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 12:20:41 +00:00
support nil in array, fix #1340
This commit is contained in:
@@ -101,14 +101,21 @@ local function compose_message(cmd, msg)
|
|||||||
local lines = {}
|
local lines = {}
|
||||||
|
|
||||||
if t == "table" then
|
if t == "table" then
|
||||||
lines[1] = count_cache[#msg+1]
|
local n = msg.n or #msg
|
||||||
|
lines[1] = count_cache[n+1]
|
||||||
lines[2] = command_cache[cmd]
|
lines[2] = command_cache[cmd]
|
||||||
local idx = 3
|
local idx = 3
|
||||||
for _,v in ipairs(msg) do
|
for i = 1, n do
|
||||||
v= tostring(v)
|
v = msg[i]
|
||||||
lines[idx] = header_cache[#v]
|
if v == nil then
|
||||||
lines[idx+1] = v
|
lines[idx] = "\r\n$-1"
|
||||||
idx = idx + 2
|
idx = idx + 1
|
||||||
|
else
|
||||||
|
v= tostring(v)
|
||||||
|
lines[idx] = header_cache[#v]
|
||||||
|
lines[idx+1] = v
|
||||||
|
idx = idx + 2
|
||||||
|
end
|
||||||
end
|
end
|
||||||
lines[idx] = "\r\n"
|
lines[idx] = "\r\n"
|
||||||
else
|
else
|
||||||
@@ -156,7 +163,7 @@ setmetatable(command, { __index = function(t,k)
|
|||||||
if type(v) == "table" then
|
if type(v) == "table" then
|
||||||
return self[1]:request(compose_message(cmd, v), read_response)
|
return self[1]:request(compose_message(cmd, v), read_response)
|
||||||
else
|
else
|
||||||
return self[1]:request(compose_message(cmd, {v, ...}), read_response)
|
return self[1]:request(compose_message(cmd, table.pack(v, ...)), read_response)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
t[k] = f
|
t[k] = f
|
||||||
@@ -175,7 +182,7 @@ end
|
|||||||
|
|
||||||
function command:sismember(key, value)
|
function command:sismember(key, value)
|
||||||
local fd = self[1]
|
local fd = self[1]
|
||||||
return fd:request(compose_message ("SISMEMBER", {key, value}), read_boolean)
|
return fd:request(compose_message ("SISMEMBER", table.pack(key, value)), read_boolean)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function compose_table(lines, msg)
|
local function compose_table(lines, msg)
|
||||||
|
|||||||
Reference in New Issue
Block a user