mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 12:43:09 +00:00
api change : redis
This commit is contained in:
@@ -9,9 +9,14 @@ local command = {}
|
|||||||
|
|
||||||
redis.cmd = command
|
redis.cmd = command
|
||||||
|
|
||||||
|
local function assert_redis(result, err, ...)
|
||||||
|
assert(result, err)
|
||||||
|
return err, ...
|
||||||
|
end
|
||||||
|
|
||||||
setmetatable(command, { __index = function(t,k)
|
setmetatable(command, { __index = function(t,k)
|
||||||
local f = function(...)
|
local f = function(...)
|
||||||
return skynet.call(".redis", skynet.unpack, skynet.pack(k, ...))
|
return assert_redis(skynet.call(".redis", skynet.unpack, skynet.pack(k, ...)))
|
||||||
end
|
end
|
||||||
t[k] = f
|
t[k] = f
|
||||||
return f
|
return f
|
||||||
@@ -19,8 +24,9 @@ end})
|
|||||||
|
|
||||||
function command.EXISTS(key)
|
function command.EXISTS(key)
|
||||||
local result , exists = skynet.call(".redis", skynet.unpack, skynet.pack("EXISTS", key))
|
local result , exists = skynet.call(".redis", skynet.unpack, skynet.pack("EXISTS", key))
|
||||||
|
assert(result, exists)
|
||||||
exists = exists ~= 0
|
exists = exists ~= 0
|
||||||
return result, exists
|
return exists
|
||||||
end
|
end
|
||||||
|
|
||||||
local function split(cmd)
|
local function split(cmd)
|
||||||
|
|||||||
Reference in New Issue
Block a user