Apply UDF on Record - aerospike-community/aerospike-client-php GitHub Wiki
Apply UDF on Record
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.