Module: Redis::Commands::Scripting
| Relationships & Source Files | |
| Extension / Inclusion / Inheritance Descendants | |
|
Included In:
| |
| Defined in: | lib/redis/commands/scripting.rb |
Instance Method Summary
-
#eval(*args) ⇒ Object
Evaluate Lua script.
-
#evalsha(*args) ⇒ Object
Evaluate Lua script by its SHA.
-
#fcall(*args) ⇒ Object
Invoke a
::RedisFunction loaded with FUNCTION LOAD. -
#fcall_ro(*args) ⇒ Object
Invoke a read-only
::RedisFunction loaded with FUNCTION LOAD. -
#function(subcommand, *args, **options) ⇒ String, ...
Manage Redis Functions libraries.
-
#script(subcommand, *args) ⇒ String, ...
Control remote script registry.
- #_eval(cmd, args) private
Instance Method Details
#_eval(cmd, args) (private)
[ GitHub ]# File 'lib/redis/commands/scripting.rb', line 211
def _eval(cmd, args) script = args.shift = args.pop if args.last.is_a?(Hash) ||= {} keys = args.shift || [:keys] || [] argv = args.shift || [:argv] || [] send_command([cmd, script, keys.length] + keys + argv) end
#eval(*args) ⇒ Object
Evaluate Lua script.
# File 'lib/redis/commands/scripting.rb', line 71
def eval(*args) _eval(:eval, args) end
#evalsha(*args) ⇒ Object
Evaluate Lua script by its SHA.
# File 'lib/redis/commands/scripting.rb', line 96
def evalsha(*args) _eval(:evalsha, args) end
#fcall(*args) ⇒ Object
Invoke a ::Redis Function loaded with FUNCTION LOAD.
# File 'lib/redis/commands/scripting.rb', line 184
def fcall(*args) _eval(:fcall, args) end
#fcall_ro(*args) ⇒ Object
Invoke a read-only ::Redis Function loaded with FUNCTION LOAD.
The function must have been registered with the no-writes flag.
# File 'lib/redis/commands/scripting.rb', line 205
def fcall_ro(*args) _eval(:fcall_ro, args) end
#function(subcommand, *args, **options) ⇒ String, ...
Manage Redis Functions libraries.
# File 'lib/redis/commands/scripting.rb', line 139
def function(subcommand, *args, **) subcommand = subcommand.to_s.downcase case subcommand when "load" command = %i[function load] command << "REPLACE" if [:replace] send_command(command + args) when "list" command = %i[function list] + args command << "LIBRARYNAME" << [:libraryname] if [:libraryname] command << "WITHCODE" if [:withcode] send_command(command, &HashifyFunctionList) when "restore" command = %i[function restore] + args command << [:policy].to_s.upcase if [:policy] send_command(command) when "stats" send_command(%i[function stats], &HashifyFunctionStats) else send_command([:function, subcommand] + args) end end
#script(subcommand, *args) ⇒ String, ...
Control remote script registry.
# File 'lib/redis/commands/scripting.rb', line 30
def script(subcommand, *args) subcommand = subcommand.to_s.downcase if subcommand == "exists" arg = args.first send_command([:script, :exists, arg]) do |reply| reply = reply.map { |r| Boolify.call(r) } if arg.is_a?(Array) reply else reply.first end end else send_command([:script, subcommand] + args) end end