mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 12:43:09 +00:00
reds pipeline v2(support function as pipeline params)
fix a bug & add function as pipeline params
This commit is contained in:
@@ -4,6 +4,7 @@ local socketchannel = require "socketchannel"
|
||||
|
||||
local table = table
|
||||
local string = string
|
||||
local assert = assert
|
||||
|
||||
local redis = {}
|
||||
local command = {}
|
||||
@@ -161,6 +162,27 @@ function command:sismember(key, value)
|
||||
return fd:request(compose_message ("SISMEMBER", {key, value}), read_boolean)
|
||||
end
|
||||
|
||||
function command:pipeline(ops)
|
||||
assert(ops and #ops > 0, "pipeline is null")
|
||||
|
||||
local fd = self[1]
|
||||
|
||||
local cmds = {}
|
||||
for _, cmd in ipairs(ops) do
|
||||
assert(#cmd >= 2, "pipeline error, the params length is less than 2")
|
||||
table.insert(cmds, compose_message(string.upper(table.remove(cmd, 1)), cmd))
|
||||
end
|
||||
|
||||
return fd:request(table.concat(cmds, "\r\n"), function (fd)
|
||||
local result = {}
|
||||
for i=1, #ops do
|
||||
local ok, out = read_response(fd)
|
||||
table.insert(result, {ok = ok, out = out})
|
||||
end
|
||||
return true, result
|
||||
end)
|
||||
end
|
||||
|
||||
--- watch mode
|
||||
|
||||
local watch = {}
|
||||
|
||||
Reference in New Issue
Block a user