Linux – lua redis handles errors

lua redis handles errors… here is a solution to the problem.

lua redis handles errors

I use a lua script to set the key for redis:

local redis = require("redis")
local connected, client = pcall(redis.connect, '', 6379)
client:set(key, value)

Sometimes, when I execute :client:set(key, value), I get an error: connection timed out and the application crashes.

How do I deal with this error issue?



local status, result = pcall(function() client:set(key, value) end)

Related Problems and Solutions