The expiring cell

Apache Cassandra allows for data in cells to be expired. This is called setting a TTL. TTLs can be applied at write-time, or they can be enforced at the table level with a default value. To set a TTL on a row at write time, utilize the USING TTL clause:

INSERT INTO query_test (pk1,pk2,ck3,ck4,c5)VALUES ('f','g','c4','d6','e7')USING TTL 86400;

Likewise, TTLs can also be applied with the UPDATE statement:

UPDATE query_testUSING TTL 86400SET c5='e7'WHERE pk1='f' AND pk2='g' AND ck3='c4' AND ck4='d6';

TTLs represent the number of seconds elapsed since write-time.

One day is 86,400 seconds.

Get Mastering Apache Cassandra 3.x - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.