Apache Cassandra™ 1.2

Setting an expiring column

Steps for setting an expiration time, or time-to-live (TTL) attribute for the data.

When you set a column in Cassandra, you can optionally set an expiration time, or time-to-live (TTL) attribute for the data. The data is not actually deleted from disk until normal Cassandra compaction processes are completed.

Procedure

Define a coupon_code column and set an expiration date on that column.
[default@demo] SET users['bobbyjo']
[utf8('coupon_code')] = utf8('SAVE20') WITH ttl=864000;
After ten days, or 864,000 seconds have elapsed since the setting of this column, its value will be marked as deleted and no longer be returned by read operations.
Loading Search