Supplying time to live information when inserting columns

Time To Live (TTL) is a setting that makes a column self-delete a specified number of seconds after the insertion time.

How to do it...

  1. Append with ttl clause to a set statement that will expire a row after ten seconds:
    [default@testkeyspace] set testcf['3']['acolumn']='avalue' with ttl = 10;
    Value inserted.
    [default@testkeyspace] get testcf['3'];                                  
    => (column=61636f6c756d6e, value=6176616c7565, timestamp=1298507877951000, ttl=10)
    Returned 1 results.
    
  2. Wait ten seconds or longer before reading again and the column will be deleted:
    [default@testkeyspace] get testcf['3'];
    Returned 0 results.
    

See also...

In Chapter 3, The Application Programmer Interface, the recipe Using TTL to create columns ...

Get Cassandra High Performance Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.