How to get LUT (last update time) of a record

The Aerospike Knowledge Base has moved to https://support.aerospike.com. Content on https://discuss.aerospike.com is being migrated to either https://support.aerospike.com or https://docs.aerospike.com. Maintenance on articles stored in this repository ceased on December 31st 2022 and this article may be stale. If you have any questions, please do not hesitate to raise a case via https://support.aerospike.com.

FAQ How to get LUT (last update time) of a record

Context

The LUT (last update time) of a record is part of a record’s meta data but is currently not returned to the clients through any direct API. The feature to add such capability is internally tracked under jira AER-5566.

As a workaround, one could use a UDF to get the LUT of a record.

Method

Using UDF, one can get the LUT of a record expressed in milliseconds since the Citrusleaf epoch (00:00:00 UTC on 1 Jan 2010).

e.g. You could define a LUA function as such (under record_example.lua for this example):

-- Return LUT of record
function getLUT(r)
    return record.last_update_time(r)
end

From the Java client, you can get the LUT like this after registering the above UDF:

                // Get record last update time.
                long lut = (Long)client.execute(params.writePolicy, key, "record_example", "getLUT");

You can use aql to register the LUA module or simply register it inside the Java application:

                RegisterTask task = client.register(params.policy, "udf/record_example.lua", "record_example.lua", Language.LUA);
                task.waitTillComplete();

Notes

  • One can use predicate filters to get records that have been last updated between two timestamps or before/after a certain timestamp.

  • If the goal is to delete specific records based on their last updated time, you could also use the truncate command.

  • If there is a clock skew between master and replica (for replication factor 2 and above) nodes within a cluster, the last update time of a record will be identical for both copies and will be as per the master node’s time.

References

Keywords

LUT METADATA UDF PREDICATE FILTERING

Timestamp

07/23/2018