CQL for Cassandra 1.2

Expiring columns

Both the INSERT and UPDATE commands support setting a time for data in a column to expire. The expiration time (TTL) is set using CQL.

Procedure

  1. Use the INSERT command to set a password column in the users table to expire in 86400 seconds, or one day.
    cqlsh:demodb> INSERT INTO users
                    (user_name, password)
                    VALUES ('cbrown', 'ch@ngem4a') USING TTL 86400;
  2. Extend the expiration period to five days by using the UPDATE command/
    cqlsh:demodb> UPDATE users USING TTL 432000 SET password = 'ch@ngem4a'
                    WHERE user_name = 'cbrown';
Show/hide