by saterenko » Tue Jun 10, 2014 4:13 am
Is there way to set ttl with UDF script? I need to create record with ttl 60 sec, not default from config file.
by saterenko » Tue Jun 10, 2014 4:13 am
Is there way to set ttl with UDF script? I need to create record with ttl 60 sec, not default from config file.
Yes, this feature is added in Aerospike Server 3.3.12
Hi wchu,
I am attempting to set the ttyl via the java api without success. Was wondering if you can help me. I verified that my server is 3.3.12.
Here is my client code (it is using aerospike java api: 3.0.22):
public Object callUserDefinedFunction(WritePolicy policy,
Key key,
Value[] list,
String luaName,
String functionName)
throws AerospikeException {
mLog.info("EXPIRATION " + policy.expiration);
return mAero.execute(policy, key, luaName,
functionName, list);
}
I log the expiration and its set properly: 2014-09-03 17:30:10 INFO UserStoreService:141 - EXPIRATION 5
The above function successfully calls my udf on the server and writes to the proper location, however it does not honor the expiration. I noticed that the execute method takes in a generic Policy type which does not have an expiration param. http://grepcode.com/file/repo1.maven.org/maven2/com.aerospike/aerospike-client/3.0.22/com/aerospike/client/AerospikeClient.java?av=f#781.
thank you for your help
Hi,
To set the ttl in a record, use the record.set_ttl() function in your UDF. The syntax is
record.set_ttl(rec, ttl)
where the ttl is in seconds. Use this function before updating or creating the record.
Thanks,
-Brad
thanks! This is what I ended up using