Articles in this section

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();
 
To register the UDF in aql, start by copying the LUA script to /opt/aerospike/usr/udf/lua
root@Test-1:/opt/aerospike/usr/udf/lua# ls -al
total 16
drwxr-xr-x 1 aerospike aerospike 4096 Dec 15 12:21 .
drwxr-xr-x 1 aerospike aerospike 4096 Feb 17  2023 ..
-rw-r--r-- 1 root      root        85 Dec 15 12:21 record_example.lua

root@Test-1:/opt/aerospike/usr/udf/lua# aql
Seed:         127.0.0.1
User:         None
Config File:  /etc/aerospike/astools.conf /root/.aerospike/astools.conf
Aerospike Query Client
Version 8.0.0
C Client Version 6.3.0
Copyright 2012-2022 Aerospike. All rights reserved.
aql> register module 'record_example.lua'
OK, 1 module added.

aql> execute record_example.getLUT() on test where PK=1
+--------------+
| getLUT       |
+--------------+
| 440335053256 |
+--------------+
1 row in set (0.001 secs)

OK

Notes


Applies To Earliest Version

4.9

Applies To Latest Version

Current Version
Was this article helpful?
0 out of 0 found this helpful