module Oxblood::Commands::Scripting

Public Instance Methods

eval(script, numkeys, *keys_and_args) click to toggle source

Execute a Lua script server side @see redis.io/commands/eval

@example

session.eval("return redis.call('set','foo','bar')", 0)
# => 'OK'

@example

session.eval("return redis.call('set',KEYS[1],'bar')", 1, :foo)
# => 'OK'

@example

session.eval("return 10", 0)
# => 10

@example

session.eval("return {1,2,{3,'Hello World!'}}", 0)
# => [1, 2, [3, 'Hello World!']]

@example

session.eval("return redis.call('get','foo')", 0)
# => 'bar'

@example

session.eval("return {1,2,3.3333,'foo',nil,'bar'}", 0)
# => [1, 2, 3, 'foo']

@param [String] script @param [Integer] numkeys @param [String, Array<String>] keys_and_args

# File lib/oxblood/commands/scripting.rb, line 36
def eval(script, numkeys, *keys_and_args)
  run(:EVAL, script, numkeys, keys_and_args)
end
evalsha(sha1, numkeys, *keys_and_args) click to toggle source

Execute a Lua script server side @see redis.io/commands/evalsha

@param [String] sha1 @param [Integer] numkeys @param [String, Array<String>] keys_and_args

# File lib/oxblood/commands/scripting.rb, line 46
def evalsha(sha1, numkeys, *keys_and_args)
  run(:EVALSHA, sha1, numkeys, keys_and_args)
end
script_debug(mode) click to toggle source

Set the debug mode for executed scripts. @see redis.io/commands/script-debug

@param [Symbol] mode

@return [String] 'OK' @return [RError] if wrong mode passed

# File lib/oxblood/commands/scripting.rb, line 57
def script_debug(mode)
  run(:SCRIPT, :DEBUG, mode)
end
script_exists(*sha1_digests) click to toggle source

Check existence of scripts in the script cache. @see redis.io/commands/script-exists

@param [String, Array<String>] sha1_digests

@return [Array<Integer>] For every corresponding SHA1 digest of a script

that actually exists in the script cache, an 1 is returned,
otherwise 0 is returned.
# File lib/oxblood/commands/scripting.rb, line 69
def script_exists(*sha1_digests)
  run(*sha1_digests.unshift(:SCRIPT, :EXISTS))
end
script_flush() click to toggle source

Remove all the scripts from the script cache. @see redis.io/commands/script-flush

@return [String] 'OK'

# File lib/oxblood/commands/scripting.rb, line 77
def script_flush
  run(:SCRIPT, :FLUSH)
end
script_kill() click to toggle source

Kill the script currently in execution. @see redis.io/commands/script-kill

@return [String] 'OK' @return [RError] if there is no script to kill

# File lib/oxblood/commands/scripting.rb, line 86
def script_kill
  run(:SCRIPT, :KILL)
end
script_load(script) click to toggle source

Load the specified Lua script into the script cache. @see redis.io/commands/script-load

@param [String] script

@return [String] This command returns the SHA1 digest of the script

added into the script cache
# File lib/oxblood/commands/scripting.rb, line 97
def script_load(script)
  run(:SCRIPT, :LOAD, script)
end