How to extend the record expiration time


#1

How to extend the record expiration time and not to reset it as Touch command do? is there any way to do this in C# client?


#2

The record’s expiration must be queried, incremented and then reset.

Record record = client.GetHeader(policy, key);

WritePolicy writePolicy = new WritePolicy();
writePolicy.expiration = record.TimeToLive + 60;  // Increment expiration ttl by 1 minute.

client.Touch(writePolicy, key);

#3

Yes,but by this way i have to query aerospike db twice and this might affect the performance, as there any way to do this by making one hit to db?


#4

You could also register and call a UDF like this one:

function add_ttl(rec, ttl_to_add)
    local ttl = record.ttl(rec)
    record.set_ttl(rec, ttl + ttl_to_add)
    aerospike:update(rec)
end