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: []) ⇒ Object
Invoke a function.
-
#fcall_ro(function, keys: [], args: []) ⇒ Object
Invoke a read-only function.
-
#function(subcommand, *args, **options) ⇒ Object
Control function registry (convenience method).
-
#function_delete(library_name) ⇒ String
Delete a library and all its functions.
-
#function_dump ⇒ String
Return the serialized payload of loaded libraries.
-
#function_flush(async: false, sync: false) ⇒ String
Delete all libraries.
-
#function_kill ⇒ String
Kill a function that is currently executing.
-
#function_list(library_name: nil, with_code: false) ⇒ Array<Hash>
Return information about the functions and libraries.
-
#function_load(function_code, replace: false) ⇒ String
Load a library to Valkey.
-
#function_restore(serialized_value, policy: nil) ⇒ String
Restore libraries from a payload.
-
#function_stats ⇒ Hash
Return information about the function that’s currently running.
Instance Method Details
#fcall(function, keys: [], args: []) ⇒ Object
Invoke a function.
189 190 191 192 |
# File 'lib/valkey/commands/function_commands.rb', line 189 def fcall(function, keys: [], args: []) command_args = [function, keys.size] + keys + args send_command(RequestType::FCALL, command_args) end |
#fcall_ro(function, keys: [], args: []) ⇒ Object
Invoke a read-only function.
206 207 208 209 |
# File 'lib/valkey/commands/function_commands.rb', line 206 def fcall_ro(function, keys: [], args: []) command_args = [function, keys.size] + keys + args send_command(RequestType::FCALL_READ_ONLY, command_args) end |
#function(subcommand, *args, **options) ⇒ Object
Control function registry (convenience method).
242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/valkey/commands/function_commands.rb', line 242 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) ⇒ String
Delete a library and all its functions.
20 21 22 |
# File 'lib/valkey/commands/function_commands.rb', line 20 def function_delete(library_name) send_command(RequestType::FUNCTION_DELETE, [library_name]) end |
#function_dump ⇒ String
Return the serialized payload of loaded libraries.
33 34 35 |
# File 'lib/valkey/commands/function_commands.rb', line 33 def function_dump send_command(RequestType::FUNCTION_DUMP) end |
#function_flush(async: false, sync: false) ⇒ String
Delete all libraries.
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/valkey/commands/function_commands.rb', line 54 def function_flush(async: false, sync: false) args = [] if async args << "ASYNC" elsif sync args << "SYNC" end send_command(RequestType::FUNCTION_FLUSH, args) end |
#function_kill ⇒ String
Kill a function that is currently executing.
75 76 77 |
# File 'lib/valkey/commands/function_commands.rb', line 75 def function_kill send_command(RequestType::FUNCTION_KILL) end |
#function_list(library_name: nil, with_code: false) ⇒ Array<Hash>
Return information about the functions and libraries.
96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/valkey/commands/function_commands.rb', line 96 def function_list(library_name: nil, with_code: false) args = [] if library_name args << "LIBRARYNAME" args << library_name end args << "WITHCODE" if with_code send_command(RequestType::FUNCTION_LIST, args) end |
#function_load(function_code, replace: false) ⇒ String
Load a library to Valkey.
124 125 126 127 128 129 130 |
# File 'lib/valkey/commands/function_commands.rb', line 124 def function_load(function_code, replace: false) args = [] args << "REPLACE" if replace args << function_code send_command(RequestType::FUNCTION_LOAD, args) end |
#function_restore(serialized_value, policy: nil) ⇒ String
Restore libraries from a payload.
153 154 155 156 157 158 159 |
# File 'lib/valkey/commands/function_commands.rb', line 153 def function_restore(serialized_value, policy: nil) args = [serialized_value] args << policy.to_s.upcase if policy send_command(RequestType::FUNCTION_RESTORE, args) end |
#function_stats ⇒ Hash
Return information about the function that’s currently running.
170 171 172 |
# File 'lib/valkey/commands/function_commands.rb', line 170 def function_stats send_command(RequestType::FUNCTION_STATS) end |