25

I have a table/column family which I am inserting rows that expire after a certain amount of time. Is it possible to then query the table to check which rows are going to expire soon (for diagnostic purposes, ie something like this:

select subject, ?ttl? from discussions;
Jay
  • 19,649
  • 38
  • 121
  • 184

1 Answers1

53

You can do

select subject, TTL(subject) from discussions;

to return the remaining TTL in seconds for subject.

E.g.

> insert into discussions (uid, subject) VALUES (now(), 'hello') using ttl 100;
> select subject, TTL(subject) from discussions;

 subject | ttl(subject)
---------+--------------
   hello |           84

since I waited 16 seconds before running the select.

Richard
  • 11,050
  • 2
  • 46
  • 33