Is it necessary to SET something while updating the TTL in Cassandra?
I have a table like this,
CREATE TABLE session(
tokenId text PRIMARY KEY,
username text);
I insert the data like this,
INSERT INTO session(tokenId, username) VALUES ('123123123123','admin') USING TTL 30;
I update the TTL like this,
UPDATE session USING TTL 30 SET username = 'admin' WHERE tokenid = '123123123123' IF EXISTS;
where It makes me forcefully update the 'username', Update demands a set, Any way to just update the TTL?
This is very tricky question. Let me try my best to explain my understanding.
Basically, cassandra doesn't allow you to update TTL for a row. TTL is maintained for each column as mentioned here. Coming back to your example, the insert
statement with TTL
value will create the same TTL for all columns in insert statement. Meanwhile, update
statement is only for intended columns (e.g. username
) only. Hope it helps.
Both the INSERT and UPDATE commands support setting a time for data in a column to expire. Use CQL to set the expiration time (TTL).