Skip to content

Instantly share code, notes, and snippets.

@korya
Created January 20, 2015 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save korya/1587fc155e9a7b0a16d7 to your computer and use it in GitHub Desktop.
Save korya/1587fc155e9a7b0a16d7 to your computer and use it in GitHub Desktop.
Debugging Redis Lua scripts

// Source: https://redislabs.com/blog/5-methods-for-tracing-and-debugging-redis-lua-scripts#.VL2w7GRNoq4

  1. Use Redis Log
redis.log(redis.LOG_WARNING, "foo bar")
  1. Return log as Lua table
local logtable = {}
local function logit(msg)
  logtable[#logtable+1] = msg
end

logit("foo")
logit("bar")

return logtable
  1. Use Redis to store the logs
local loglist = "log"
-- DEL log
local function logit(msg)
  redis.pcall("RPUSH", loglist, msg)
end
-- LRANGE log 0 -1

logit("foo")
logit("bar")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment