hackfengJam / blog

my tech blog, using markdown
34 stars 5 forks source link

Redis eval命令踩得那些坑 #21

Open hackfengJam opened 3 years ago

hackfengJam commented 3 years ago

根据 key 是否存在,返回 404

BAD

local rst = redis.call("hmget",KEYS[1],"remain","lock",ARGV[1])
rst[1] == nil then
    return 404
end

GOOD

local rst = redis.call("hmget",KEYS[1],"remain","lock",ARGV[1])
rst[1] == nil or rst[1] == false then
    return 404
end
hackfengJam commented 3 years ago