mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 20:23:06 +00:00
Update: use pipeline for ASKING command in redis cluster (#2097)
- ensure ASKING and command execute sequentially and consecutively - save one RTT
This commit is contained in:
@@ -344,15 +344,24 @@ function rediscluster:call(...)
|
|||||||
else
|
else
|
||||||
conn = self:get_connection_by_slot(slot)
|
conn = self:get_connection_by_slot(slot)
|
||||||
end
|
end
|
||||||
local result = {pcall(function ()
|
|
||||||
-- TODO: use pipelining to send asking and save a rtt.
|
local result
|
||||||
if asking then
|
if asking then
|
||||||
conn:asking()
|
-- use pipeline
|
||||||
end
|
-- ensure ASKING and command execute sequentially and consecutively
|
||||||
|
-- save one RTT
|
||||||
|
local cmd_list = {
|
||||||
|
{ "asking" },
|
||||||
|
{ ... },
|
||||||
|
}
|
||||||
asking = false
|
asking = false
|
||||||
|
local func = conn["pipeline"]
|
||||||
|
result = { pcall(func, conn, cmd_list) }
|
||||||
|
else
|
||||||
local func = conn[cmd]
|
local func = conn[cmd]
|
||||||
return func(conn,table.unpack(argv,2))
|
result = { pcall(func, conn, table.unpack(argv, 2)) }
|
||||||
end)}
|
end
|
||||||
|
|
||||||
local ok = result[1]
|
local ok = result[1]
|
||||||
if not ok then
|
if not ok then
|
||||||
err = table.unpack(result,2)
|
err = table.unpack(result,2)
|
||||||
|
|||||||
Reference in New Issue
Block a user