view raw
SKR SKR - 9 months ago 37
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

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.