以下是我的Lua脚本:
那么……我该如何在lua中实现这个呢?
local ckid = redis.pcall('get',KEYS[1])
local meta = redis.call('hgetall', ckid)
return {ckid, meta}
如果第一次调用时键不存在,我不希望执行第二次调用。
那么……我不知道返回值为None的含义。在Python中,返回值将是None。
if ckid ~= '???????' then
local meta = redis.call('hgetall', ckid)
else
local meta = 'empty'
retrun {ckid, meta}
那么……我该如何在lua中实现这个呢?
local ckid = redis.pcall('get',KEYS[1])
if ckid ~= nil then
local meta = redis.call('hgetall', ckid)
else
local meta = 'none'
local ckid = 'none'
end
return {ckid, meta}
When using nil..
ResponseError: ERR Error running script (call to f_1400713412b0063a26eb0dc063f53a4e3be26380): user_script:12: Script attempted to access unexisting global variable 'meta'
false
,而在Redis中返回nil
。 - Luper Rouch