Reputation: 2644
Is there any way in Cassandra to set TTL for only one record (one column), not for entire row. For ex, there is a table which has temporary users data and in it their is a field OTP which expires in 30 minutes. I'm trying to figure out how to set TTL only on OTP record not on entire user field row.
All the examples I found so far sets TTL on entire row not on any specific record. I'm using Spring Data for Cassandra.
Upvotes: 0
Views: 343
Reputation: 12850
Insert the field using separate query with TTL
If your table name is users
and primary key is userid
then insert the OTP
field with userid
using TTL 30 * 60 = 1800 seconds
INSERT INTO users(userid, OTP) values(?, ?) USING TTL 1800;
Upvotes: 4