suppose the table name : company_employee
select * from company_employee ;
company_id | company_name | employee_id_name_map | employee_id_department_map
------------+--------------+------------------------------+---------------------------
123 | abc | {'1': 'john'} ,{'2': 'jack'} | {'1': 'tech'} ,{'2': 'hr'}
Here I wanted to set TTL for a employee_id_name_map element "{'1': 'john'}" as 30 and for employee_id_department_map element "{'1': 'tech'}" as 40 is there any way to update both elements using single Cassandra command ?
I have tried by setting ttl for individual element in map using individual command like below
UPDATE company_employee USING TTL 30 SET employee_id_name_map['1']='john' WHERE company_id='123' and company_name = 'abc';
UPDATE company_employee USING TTL 40 SET employee_id_department_map['1']='tech' WHERE company_id='123' and company_name = 'abc';
using above cassandra commands its worked good , but i wanted to get in a single cassandra write , any good suggestion helps me alot ..
Thanks in advance
No, you can't set different TTLs in one CQL statement. But you can use batches to combine several commands into a single Cassandra write (if you work on the same partition key). Like this:
BEGIN BATCH
UPDATE company_employee USING TTL 30 SET employee_id_name_map['1']='john' WHERE company_id='123' and company_name = 'abc';
UPDATE company_employee USING TTL 40 SET employee_id_department_map['1']='tech' WHERE company_id='123' and company_name = 'abc';
APPLY BATCH;