Module: Valkey::Commands::ModuleCommands
- Included in:
- Valkey::Commands
- Defined in:
- lib/valkey/commands/module_commands.rb
Overview
This module contains commands related to Valkey Modules.
Instance Method Summary collapse
-
#module(subcommand, *args, **options) ⇒ Object
Control module registry (convenience method).
-
#module_list ⇒ Array<Hash>
List all loaded modules.
-
#module_load(path, *args) ⇒ String
Load a module.
-
#module_loadex(path, configs: {}, args: []) ⇒ String
Load a module with extended options.
-
#module_unload(name) ⇒ String
Unload a module.
Instance Method Details
#module(subcommand, *args, **options) ⇒ Object
Control module registry (convenience method).
112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/valkey/commands/module_commands.rb', line 112 def module(subcommand, *args, **) subcommand = subcommand.to_s.downcase if args.empty? && .empty? send("module_#{subcommand}") elsif .empty? send("module_#{subcommand}", *args) else send("module_#{subcommand}", *args, **) end end |
#module_list ⇒ Array<Hash>
List all loaded modules.
19 20 21 |
# File 'lib/valkey/commands/module_commands.rb', line 19 def module_list send_command(RequestType::MODULE_LIST) end |
#module_load(path, *args) ⇒ String
Load a module.
37 38 39 40 |
# File 'lib/valkey/commands/module_commands.rb', line 37 def module_load(path, *args) command_args = [path] + args send_command(RequestType::MODULE_LOAD, command_args) end |
#module_loadex(path, configs: {}, args: []) ⇒ String
Load a module with extended options.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/valkey/commands/module_commands.rb', line 74 def module_loadex(path, configs: {}, args: []) command_args = [path] unless configs.empty? command_args << "CONFIG" configs.each do |key, value| command_args << key.to_s command_args << value.to_s end end unless args.empty? command_args << "ARGS" command_args.concat(args) end send_command(RequestType::MODULE_LOAD_EX, command_args) end |
#module_unload(name) ⇒ String
Unload a module.
52 53 54 |
# File 'lib/valkey/commands/module_commands.rb', line 52 def module_unload(name) send_command(RequestType::MODULE_UNLOAD, [name]) end |