现在的位置: 首页 > 综合 > 正文

redis.pcall返回错误的处理

2019年11月19日 ⁄ 综合 ⁄ 共 276字 ⁄ 字号 评论关闭

set abc 123

zadd z 0 abc

eval "local c=redis.pcall('get', KEYS[1]) if (c.err) then return c.err else return c end" 1 abc

eval "local c=redis.pcall('get', KEYS[1]) if (c.err) then return c.err else return c end" 1 z


当调用redis.pcall的过程中有出现错误,则redis.pcall调用返回带有err域的Table。

通过c.err来判断此域是否为空。

如不为空则表示有错误发生。为空则无错,是正常执行的结果。

抱歉!评论已关闭.