As Cassandra DB is providing a option to set Time-to-live(TTL) value to automatically delete the record on the basis of TTL value set with record. I have a case that user can change the date of data expiry, means user can change the data expiration date any time.
Case:
Requirement: Whenever user changes the expiration period through UI, we wanted to change TTL in database. Is there any option to update the TTL for records in Cassandra DB.
I did some R&D on this issue and I have concluded following points.
You can perform a "fake update"
INSERT INTO ttl_example (k, v) VALUES ('somekey', 'somevalue') USING TTL 60;
UPDATE ttl_example USING TTL 200 SET v = 'somevalue' WHERE k = 'somekey';
After the execution of second statement TTL will be 200 seconds.
HTH, Carlo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With