Is it possible to do touch operation from UDF (Lua)? or is the update/exists operations do the touch automatically?
We use the last Aerospike version.
Thanks, Avi
Is it possible to do touch operation from UDF (Lua)? or is the update/exists operations do the touch automatically?
We use the last Aerospike version.
Thanks, Avi
The effect of a touch operation is to update the TTL and increment the generation of the record, and this can be done directly in UDF in the following example:
function update_ttl( rec ) record.set_ttl( rec, updatedttl ) status = aerospike:update( rec ) end
The record.exists() function is a read-only function, and thus will not increment the record generation nor the TTL. A record.update() w/o having updated any bin or metadata (such as the TTL) is also a no-op.
You could set TTL -2 to keep the existing TTL as-is, and apply that record UDF to a scan of the namespace/set.
function touch_rec(rec)
record.set_ttl(rec, -2)
aerospike:update(rec)
end
Then
from __future__ import print_function
import aerospike
client = aerospike.client({ 'hosts': [('33.33.33.2', 3000)] }).connect()
client.scan_apply('test','testset','touchy','touch_rec',
options={'priority': aerospike.SCAN_PRIORITY_LOW})