lib/redis_scripts.rb
def run(name, *args)
    script = script(name)
    begin
      redis.evalsha script.sha, *args
    rescue Redis::CommandError => error
      error.message.include?('NOSCRIPT') or
        raise
      sha, value = redis.pipelined do
        redis.script 'load', script.content
        redis.evalsha(script.sha, *args)
      end
      sha == script.sha or
        raise SHAMismatch, "SHA mismatch for #{name}: expected #{script.sha}, got #{sha}"
      value
    end
  end
# Run the script named +name+ with the given +args+.
#
# +name+ is the path of the script relative to the +load_path+, minus the
# '.lua' extension. So if the load_path contains 'scripts', and the script is
# at 'scripts/foo/bar.lua', then +name+ should be 'foo/bar'. +name+ may be a
# string or symbol.
#
# +args+ are passed to Redis#evalsha (see documentation for the Redis gem). If
# the script is not yet loaded in the redis script cache, it is loaded and
# called again. Note that this means this should not be called inside a MULTI
# transaction - this is usually not a problem, since the purpose of scripting
# is to perform a sequence of atomic operations in a single command.
#
# Raises ArgumentError if no such script exists.
Run the script named +name+ with the given +args+.
+name+ is the path of the script relative to the +load_path+, minus the
'.lua' extension.

+args+ are passed to Redis#evalsha . If
the script is not yet loaded in the redis script cache, it is loaded and
called again. Note that this means this should not be called inside a MULTI
transaction - this is usually not a problem, since the purpose of scripting
is to perform a sequence of atomic operations in a single command.

Raises ArgumentError if no such script exists.
Run the script named + name + with the given + args + . + name + is the path of the script relative to the + load_path + minus the ' . lua ' extension . + args + are passed to Redis#evalsha . If the script is not yet loaded in the redis script cache it is loaded and called again . Note that this means this should not be called inside a MULTI transaction - this is usually not a problem since the purpose of scripting is to perform a sequence of atomic operations in a single command . Raises ArgumentError if no such script exists .
def run(name, *args)
    script = script(name)
    begin
      redis.evalsha script.sha, *args
    rescue Redis::CommandError => error
      error.message.include?('NOSCRIPT') or
        raise
      sha, value = redis.pipelined do
        redis.script 'load', script.content
        redis.evalsha(script.sha, *args)
      end
      sha == script.sha or
        raise SHAMismatch, "SHA mismatch for #{name}: expected #{script.sha}, got #{sha}"
      value
    end
  end
def run ( name , * args ) script = script ( name ) begin redis . evalsha script . sha , * args rescue Redis :: CommandError => error error . message . include? ( 'NOSCRIPT' ) or raise sha , value = redis . pipelined do redis . script 'load' , script . content redis . evalsha ( script . sha , * args ) end sha == script . sha or raise SHAMismatch , "SHA mismatch for #{name}: expected #{script.sha}, got #{sha}" value end end
Run the script named +name+ with the given +args+.
Run the script named + name + with the given + args + .
name
args