Module: Valkey::Commands::FunctionCommands
- Included in:
- Valkey::Commands
- Defined in:
- lib/valkey/commands/function_commands.rb
Overview
This module contains commands related to Valkey Functions.
Instance Method Summary collapse
-
#fcall(function, keys: [], args: [], route: nil) ⇒ Object
Invoke a function.
-
#fcall_ro(function, keys: [], args: [], route: nil) ⇒ Object
Invoke a read-only function.
-
#function(subcommand, *args, **options) ⇒ Object
Control function registry (convenience method).
-
#function_delete(library_name, route: nil) ⇒ String
Delete a library and all its functions.
-
#function_dump(route: nil) ⇒ String
Return the serialized payload of loaded libraries.
-
#function_flush(async: false, sync: false, route: nil) ⇒ String
Delete all libraries.
-
#function_kill(route: nil) ⇒ String
Kill a function that is currently executing.
-
#function_list(library_name: nil, with_code: false, route: nil) ⇒ Array<Hash>
Return information about the functions and libraries.
-
#function_load(function_code, replace: false, route: nil) ⇒ String
Load a library to Valkey.
-
#function_restore(serialized_value, policy: nil, route: nil) ⇒ String
Restore libraries from a payload.
-
#function_stats(route: nil) ⇒ Hash
Return information about the function that's currently running.
Instance Method Details
#fcall(function, keys: [], args: [], route: nil) ⇒ Object
Invoke a function.
198 199 200 201 |
# File 'lib/valkey/commands/function_commands.rb', line 198 def fcall(function, keys: [], args: [], route: nil) command_args = [function, keys.size] + keys + args send_command(RequestType::FCALL, command_args, route: route) end |
#fcall_ro(function, keys: [], args: [], route: nil) ⇒ Object
Invoke a read-only function.
216 217 218 219 |
# File 'lib/valkey/commands/function_commands.rb', line 216 def fcall_ro(function, keys: [], args: [], route: nil) command_args = [function, keys.size] + keys + args send_command(RequestType::FCALL_READ_ONLY, command_args, route: route) end |
#function(subcommand, *args, **options) ⇒ Object
Control function registry (convenience method).
252 253 254 255 256 257 258 259 260 261 262 |
# File 'lib/valkey/commands/function_commands.rb', line 252 def function(subcommand, *args, **) subcommand = subcommand.to_s.downcase if args.empty? && .empty? send("function_#{subcommand}") elsif .empty? send("function_#{subcommand}", *args) else send("function_#{subcommand}", *args, **) end end |
#function_delete(library_name, route: nil) ⇒ String
Delete a library and all its functions.
21 22 23 |
# File 'lib/valkey/commands/function_commands.rb', line 21 def function_delete(library_name, route: nil) send_command(RequestType::FUNCTION_DELETE, [library_name], route: route) end |
#function_dump(route: nil) ⇒ String
Return the serialized payload of loaded libraries.
35 36 37 |
# File 'lib/valkey/commands/function_commands.rb', line 35 def function_dump(route: nil) send_command(RequestType::FUNCTION_DUMP, [], route: route) end |
#function_flush(async: false, sync: false, route: nil) ⇒ String
Delete all libraries.
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/valkey/commands/function_commands.rb', line 57 def function_flush(async: false, sync: false, route: nil) args = [] if async args << "ASYNC" elsif sync args << "SYNC" end send_command(RequestType::FUNCTION_FLUSH, args, route: route) end |
#function_kill(route: nil) ⇒ String
Kill a function that is currently executing.
79 80 81 |
# File 'lib/valkey/commands/function_commands.rb', line 79 def function_kill(route: nil) send_command(RequestType::FUNCTION_KILL, [], route: route) end |
#function_list(library_name: nil, with_code: false, route: nil) ⇒ Array<Hash>
Return information about the functions and libraries.
101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/valkey/commands/function_commands.rb', line 101 def function_list(library_name: nil, with_code: false, route: nil) args = [] if library_name args << "LIBRARYNAME" args << library_name end args << "WITHCODE" if with_code send_command(RequestType::FUNCTION_LIST, args, route: route) end |
#function_load(function_code, replace: false, route: nil) ⇒ String
Load a library to Valkey.
130 131 132 133 134 135 136 |
# File 'lib/valkey/commands/function_commands.rb', line 130 def function_load(function_code, replace: false, route: nil) args = [] args << "REPLACE" if replace args << function_code send_command(RequestType::FUNCTION_LOAD, args, route: route) end |
#function_restore(serialized_value, policy: nil, route: nil) ⇒ String
Restore libraries from a payload.
160 161 162 163 164 165 166 |
# File 'lib/valkey/commands/function_commands.rb', line 160 def function_restore(serialized_value, policy: nil, route: nil) args = [serialized_value] args << policy.to_s.upcase if policy send_command(RequestType::FUNCTION_RESTORE, args, route: route) end |
#function_stats(route: nil) ⇒ Hash
Return information about the function that's currently running.
178 179 180 |
# File 'lib/valkey/commands/function_commands.rb', line 178 def function_stats(route: nil) send_command(RequestType::FUNCTION_STATS, [], route: route) end |