Daily Cassandra Data Cleanup?

I have a family of columns inside cassandra that is used to store daily information. Being daily, I believe that it needs to be removed every day.

So, I would like to know if you can configure cassandra to clear this data.

I came here because I did not find any deeper information about data cleansing on the cassandra page.

Thanks!

+4
source share
2 answers

Not used it yet, but Cassandra 0.7 has TTL for columns. Perhaps this will help you, it will basically delete the columns after a certain period of time:

datastax blog post

+4
source

I know this is an old question, but for any googlers that come wanting an answer on version 2.x +, here is the DataStax document on Live Time Definition (TTL). Using CQL with the excelsior keyspace and clicks column family, you create your table as usual:

 CREATE TABLE excelsior.clicks ( userid uuid, url text, name text, PRIMARY KEY (userid, url) ); 

When you insert your data, you specify the USING TTL , followed by the number of seconds during which the data must be stored for:

 INSERT INTO excelsior.clicks ( userid, url, name) VALUES ( 3715e600-2eb0-11e2-81c1-0800200c9a66, 'http://apache.org', 'Mary') USING TTL 86400; 

Please note that 86400 is the number of seconds per day. You can also set TTL using a prepared statement in the Java CQL Driver by simply processing it like any other related parameter:

 String strCQL = "INSERT INTO excelsior.clicks (userid, url, name) " + "VALUES (?,?,?) USING TTL ? "; boundStatement = new BoundStatement(statement); mySession.execute(boundStatement.bind( UUID.fromString("3715e600-2eb0-11e2-81c1-0800200c9a66"), "http://apache.org", "Mary", 86400) ); 
0
source

Source: https://habr.com/ru/post/1396401/


All Articles