SKR SKR - 1 year ago 117
Java Question

TTL get from ROW object of datastax java driver

How can we get TTL of a ROW returned from Cassandra.

Currently i am fetching TTL as part of Select cql query , e.g. SELECT NO,TTL;
And then using Row.getInt("TTL");

Is there any other better way to do this.

Ali Ali
Answer Source

TTLs are set per cells and not rows. If you want to get select val, TTL(val) from test; to show you the remaining TTL in seconds

For example

> insert into test (id, val) VALUES (uuid(), 'some value') using ttl 100;
> select val, TTL(val) from test;

 val           | ttl(val)
   hello world |      92

I executed the select query 8 seconds after inserting the row.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download