Setting an Expiring Column
When you set a column in Cassandra, you can optionally set an expiration time, or “time-to-live” (ttl) attribute for it. In this example we will imagine that the user jsmith gets assigned a web session token that lasts for ten days before he needs to log in again. To accomplish this, the column session_token is set with a ttl value of 864000:
[default@twissandra]set users['jsmith']['session_token']='ten' with ttl=864000; Value inserted. [default@twissandra] get users['jsmith'] as ascii; => (column=password, value=ch@ngem3, timestamp=1295635612024000)=> (column=session_token, value=74656e, timestamp=1295898172256000, ttl=864000) Returned 2 results.After ten days, or 864,000 seconds have elapsed since the setting of this column, its value will no longer be returned by read operations. Note, however, that the value is not actually deleted from disk until normal Cassandra tombstoning and compaction processes are completed