mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 12:43:09 +00:00
@@ -1,10 +1,16 @@
|
|||||||
local skynet = require "skynet"
|
|
||||||
local socket = require "skynet.socket"
|
|
||||||
local socketchannel = require "skynet.socketchannel"
|
local socketchannel = require "skynet.socketchannel"
|
||||||
|
|
||||||
|
local tostring = tostring
|
||||||
|
local tonumber = tonumber
|
||||||
local table = table
|
local table = table
|
||||||
local string = string
|
local string = string
|
||||||
local assert = assert
|
local assert = assert
|
||||||
|
local setmetatable = setmetatable
|
||||||
|
local ipairs = ipairs
|
||||||
|
local type = type
|
||||||
|
local select = select
|
||||||
|
local pairs = pairs
|
||||||
|
|
||||||
|
|
||||||
local redis = {}
|
local redis = {}
|
||||||
local command = {}
|
local command = {}
|
||||||
@@ -116,7 +122,7 @@ local function compose_message(cmd, msg)
|
|||||||
lines[2] = command_cache[cmd]
|
lines[2] = command_cache[cmd]
|
||||||
local idx = 3
|
local idx = 3
|
||||||
for i = 1, n do
|
for i = 1, n do
|
||||||
v = msg[i]
|
local v = msg[i]
|
||||||
if v == nil then
|
if v == nil then
|
||||||
lines[idx] = "\r\n$-1"
|
lines[idx] = "\r\n$-1"
|
||||||
idx = idx + 1
|
idx = idx + 1
|
||||||
@@ -221,7 +227,7 @@ function command:pipeline(ops,resp)
|
|||||||
|
|
||||||
if resp then
|
if resp then
|
||||||
return fd:request(cmds, function (fd)
|
return fd:request(cmds, function (fd)
|
||||||
for i=1, #ops do
|
for _=1, #ops do
|
||||||
local ok, out = read_response(fd)
|
local ok, out = read_response(fd)
|
||||||
table.insert(resp, {ok = ok, out = out})
|
table.insert(resp, {ok = ok, out = out})
|
||||||
end
|
end
|
||||||
@@ -230,7 +236,7 @@ function command:pipeline(ops,resp)
|
|||||||
else
|
else
|
||||||
return fd:request(cmds, function (fd)
|
return fd:request(cmds, function (fd)
|
||||||
local ok, out
|
local ok, out
|
||||||
for i=1, #ops do
|
for _=1, #ops do
|
||||||
ok, out = read_response(fd)
|
ok, out = read_response(fd)
|
||||||
end
|
end
|
||||||
-- return last response
|
-- return last response
|
||||||
@@ -307,18 +313,18 @@ function watch:message()
|
|||||||
local so = self.__sock
|
local so = self.__sock
|
||||||
while true do
|
while true do
|
||||||
local ret = so:response(read_response)
|
local ret = so:response(read_response)
|
||||||
local type , channel, data , data2 = ret[1], ret[2], ret[3], ret[4]
|
local ttype , channel, data , data2 = ret[1], ret[2], ret[3], ret[4]
|
||||||
if type == "message" then
|
if ttype == "message" then
|
||||||
return data, channel
|
return data, channel
|
||||||
elseif type == "pmessage" then
|
elseif ttype == "pmessage" then
|
||||||
return data2, data, channel
|
return data2, data, channel
|
||||||
elseif type == "subscribe" then
|
elseif ttype == "subscribe" then
|
||||||
self.__subscribe[channel] = true
|
self.__subscribe[channel] = true
|
||||||
elseif type == "psubscribe" then
|
elseif ttype == "psubscribe" then
|
||||||
self.__psubscribe[channel] = true
|
self.__psubscribe[channel] = true
|
||||||
elseif type == "unsubscribe" then
|
elseif ttype == "unsubscribe" then
|
||||||
self.__subscribe[channel] = nil
|
self.__subscribe[channel] = nil
|
||||||
elseif type == "punsubscribe" then
|
elseif ttype == "punsubscribe" then
|
||||||
self.__psubscribe[channel] = nil
|
self.__psubscribe[channel] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user