Led makes managing Redis Lua scripts simple and easy. Features:
gem install led
Led.add_script(:add, 'return tonumber(ARGV[1])+tonumber(ARGV[2])')
Led.add(12, 34) # => 46
Led.add_script(:interpolate, 'return "abc_#{ARGV[1]}"')
Led.interpolate('def') # => "abc_def"
Led.add_script(:set, 'SET(ARGV[1], ARGV[2])') # silly example, I know
# same as redis.call('set', ARGV[1], ARGV[2])
-- helpers.lua
local function add(x, y)
return x + y
end
-- test.lua
__include 'helpers'
return add(ARGV[1], ARGV[2])
Led.script_dir = '.'
# once the script dir is set, scripts files are loaded automatically.
Led.test(1, 2) # => 3