Project

led

0.0
No commit activity in last 3 years
No release in over 3 years
Script-based ORM for Redis
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0.6.1
>= 4.0.1
 Project Readme

Easy Lua scripting for Redis

Led makes managing Redis Lua scripts simple and easy. Features:

Installing

gem install led

How to use it

Install scripts as Ruby methods:

Led.add_script(:add, 'return tonumber(ARGV[1])+tonumber(ARGV[2])')
Led.add(12, 34) # => 46

String interpolation for lua:

Led.add_script(:interpolate, 'return "abc_#{ARGV[1]}"')
Led.interpolate('def') # => "abc_def"

Shorthand for redis calls:

Led.add_script(:set, 'SET(ARGV[1], ARGV[2])') # silly example, I know
# same as redis.call('set', ARGV[1], ARGV[2])

Reuse code by using includes:

-- 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