Lua scripts for analytics with Redis