This repository has been archived by the owner on May 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Apply UDF on Record
Mira Dytko edited this page Jan 20, 2022
·
4 revisions
Use the Aerospike PHP client to apply a UDF on a record. Invoke the apply()
Record UDF to perform an operation on a single record.
UDFs must register with the Aerospike server.
Provide the following to apply a UDF on a record:
- key tuple — Address a record in the database.
- module name — The UDF module.
- function name — The UDF function.
- function arguments — The arguments for the UDF function.
The example uses the registered a UDF module, sample
, which contains the following function:
function list_append(rec, bin, value)
local l = rec[bin]
list.append(l, value)
rec[bin] = l
aerospike:update(rec)
return 0
end
list_append()
appends a value to the bin containing a list, and then updates the record.
To invoke list_append()
and append "!!!" to the things bin:
$key = $db->initKey('test', 'demo', 'foo');
$db->apply($key, "sample", "list_append", ["things", "!!!"]);
Refer to the User-Defined Functions (UDF) Development Guide.
PHP Client