Skip to content
Webinar - May 13th: How Criteo powers real-time decisions with a reduced footprintRegister now

Manage UDFs

Register

To register UDFs, you must first group them in a module and then register that UDF module with the Aerospike server cluster using Client.register_udf:

# To automatically read the a UDF source file
def register_udf_from_file(client_path, server_path, language=Aerospike::Language::LUA, options={})
# Supply the UDF source as a string
def register_udf(udf_body, server_path, language=Aerospike::Language::LUA, options={})

Where:

  • udf_body — The UDF source.
  • client_path — The local path to the UDF module.
  • server_path — The UDF module to store in the cluster.
  • language — The UDF module language.

This example registers the example.lua UDF module as a LUA language module:

task = client.register_udf_from_file("udf/example.lua", "example.lua")

UDF modules register asynchronously, which means that the server can return before the UDF module is available on all nodes. The client can use wait_till_completed to wait until the asynchronous task completes:

# to block until the UDF is created
task.wait_till_completed
# task is completed successfully

Once registration completes, the UDFs can be called from the Aerospike Ruby client.

List

Use the Aerospike Ruby client to manage a list of UDFs.

To get a list of registered UDFs on the server:

client.list_udf

An array of Aerospike::UDF objects returns with information about each UDF.

Remove

User-Defined Functions (UDFs) are grouped in a module you can remove from the server.

To remove a UDF using Client.remove_udf:

def remove_udf(udf_name, options={})

Where:

  • udf_name is the UDF module name.

To asynchronously delete the example.lua UDF module:

task = client.remove_udf("udf/example.lua")

To block the call until the UDF is removed:

# to block until the UDF is removed
task.wait_till_completed
Feedback

Was this page helpful?

What type of feedback are you giving?

What would you like us to know?

+Capture screenshot

Can we reach out to you?