3

So I know that TTL is not available for counters because of design reasons and I've read https://issues.apache.org/jira/browse/CASSANDRA-2103 as well as some other SO questions regarding this but there seems to be no clear answer(unless I am missing something which is entirely plausible):

How do we elegantly handle the expiration of counters in Cassandra?

Example use case: page views on a specific day.

For this we might have a table such as

CREATE TABLE pageviews (page varchar, date varchar, views counter, PRIMARY KEY(page, date));

One year from now the information of how many views we had on one specific day is not very relevant (instead we might have aggregated it into a view/month table or similar) and we don't want unnecessary data hanging around in our db for no reason. Normally we would put a TTL on this and let Cassandra handle it for us - elegant! But since we aren't allowed to use TTL for counter tables this is not an option..

My only idea is to run a nightly cron job expiring data - which feels less nice since the rest of data ageing is handled by Cassandra.

Surely someone else must have encountered this issue with Cassandra and come up with a neater solution?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.