In Amazon Keyspaces, you can set a default TTL value for all rows in a table when the table is created.
The default TTL value for a table is zero, which means that data doesn't expire automatically. If the default TTL value for a table is greater than zero, an expiration timestamp is added to each row.
TTL values are set in seconds, and the maximum configurable value is 630,720,000 seconds, which is the equivalent of 20 years.
After table creation, you can overwrite the table's default TTL setting for specific rows or columns with CQL DML statements. For more information, see Use the INSERT statement to set custom Time to Live (TTL) values for new rows and Use the UPDATE statement to edit custom Time to Live (TTL) settings for rows and columns.
When you enable TTL on a table, Amazon Keyspaces begins to store additional TTL-related metadata for each row. In addition, TTL uses expiration timestamps to track when rows or columns expire. The timestamps are stored as row metadata and contribute to the storage cost for the row.
After the TTL feature is enabled, you can't disable it for a
table. Setting the table’s default_time_to_live
to 0 disables default
expiration times for new data, but it doesn't deactivate the TTL feature or revert the
table back to the original Amazon Keyspaces storage metadata or write behavior.
The following examples show how to create a new table with a default TTL value.
Create a new table with a Time to Live default value using the console.
Sign in to the AWS Management Console, and open the Amazon Keyspaces console at https://console.aws.amazon.com/keyspaces/home
. -
In the navigation pane, choose Tables, and then choose Create table.
-
On the Create table page in the Table details section, select a keyspace and provide a name for the new table.
-
In the Schema section, create the schema for your table.
In the Table settings section, choose Customize settings.
-
Continue to Time to Live (TTL).
In this step, you select the default TTL settings for the table.
For the Default TTL period, enter the expiration time and choose the unit of time you entered, for example seconds, days, or years. Amazon Keyspaces will store the value in seconds.
-
Choose Create table. Your table is created with the specified default TTL value.