There are times when keeping stored information forever might not be required. For this, it would be necessary to implement processes that are constantly cleaning a database. However, these types of processes could generate an operational load for a company or, much worse, they eventually tend to fail. That is why DynamoDB offers us a functionality in which we can configure the lifetime of the records in the database.

Understanding Time To Live

Time to live (TTL) is a concept that’s been around in the tech industry for a long time. It allows us to indicate how long a record, an object or any other piece of data managed by a system is valid. Normally, after the time when things are not valid, two events can occur. The first is that the registry would have to be refreshed from a source system. The second is that the record would have to be permanently deleted.

TTL in DynamoDB

In DynamoDB, TTL allows us to configure the records so that they are automatically deleted when they meet a certain condition. It’s important to emphasize that this process is automatic. All we have to do is configure the database.

It is also important to mention that this functionality is free, which means that we do not have to pay any extra money to configure it. However, it’s good to note that this doesn’t consume RCUs or WCUs, but does consume burst capacity.

How TTL works in DynamoDB

TTL works based on a field that is indicated to DynamoDB. This field is a numeric type and is based on the epoch format. This field will contain a date, which is down to the number of seconds. This date is when records should be deleted.

Get hands-on with 1200+ tech skills courses.