Using Time To Live(TTL) for spring data cassandra repository
Using Time To Live(TTL) for spring data cassandra repository
Refer to A Sarkars answer from this post TTL support in spring boot application using spring-data-cassandra
Please see my sample code here, https://github.com/nontster/spring-data-cassandra-demo
I borrow sample code from this tutorial https://www.baeldung.com/spring-data-cassandra-tutorial
You need to create demo keyspace before you can run this code,
CREATE KEYSPACE demo WITH replication = {class:SimpleStrategy, replication_factor : 1};
Run saveBookTest() method in BookRepositoryIntegrationTest.java and you can see countdown TTL in column via (I set TTL to 600 seconds)
cqlsh:demo> SELECT title,TTL(year) FROM Book WHERE title=Head First Java AND publisher=OReilly Media;
title | ttl(year)
-----------------+-----------
Head First Java | 597
(1 rows)