From ed7e0da86046330f083e9f88618803590360e728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=91=E9=A3=8E?= Date: Tue, 14 Aug 2012 23:44:51 +0800 Subject: [PATCH] api change : redis --- lualib/redis.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lualib/redis.lua b/lualib/redis.lua index a367768a..14ddec5b 100644 --- a/lualib/redis.lua +++ b/lualib/redis.lua @@ -9,9 +9,14 @@ local command = {} redis.cmd = command +local function assert_redis(result, err, ...) + assert(result, err) + return err, ... +end + setmetatable(command, { __index = function(t,k) local f = function(...) - return skynet.call(".redis", skynet.unpack, skynet.pack(k, ...)) + return assert_redis(skynet.call(".redis", skynet.unpack, skynet.pack(k, ...))) end t[k] = f return f @@ -19,8 +24,9 @@ end}) function command.EXISTS(key) local result , exists = skynet.call(".redis", skynet.unpack, skynet.pack("EXISTS", key)) + assert(result, exists) exists = exists ~= 0 - return result, exists + return exists end local function split(cmd)