Does DynamoDB support TTL based on specific conditions? For example, I want the TTL to be enabled on records with a specific attribute and no TTL on records which does not have a value for that attribute.
The docs I've currently read to look into this issue are
Both the docs indicate no specific information on that.
Thanks,
TTL typically deletes expired items within 48 hours of expiration.
The key statement, as you pointed out, is at How It Works: DynamoDB Time to Live (TTL): Items that are past their expiration, but have not yet been deleted can still be updated, and successful updates to change or remove the expiration attribute will be honored.
Sign in to the AWS Management Console and open the DynamoDB console at https://console.aws.amazon.com/dynamodb/ . Choose Tables, and then choose the table that you want to modify. In the Additional settings tab, in the Time to Live (TTL) section, choose Enable.
Yes according to the link you sent. DynamoDB typically deletes expired items within 48 hours of expiration. The exact duration within which an item truly gets deleted after expiration is specific to the nature of the workload and the size of the table.
Remember that DynamoDB is schemaless. All records do not have to have the same fields. So, only create the TTL field on the records which you wish to have expired. When the record is updated such that your "condition" is met, add the TTL field.
TTL compares a non-empty filed (which has been set as TTL field) in DynamoDB with current timestamp, delete the item if its TTL field is earlier than current time stamp.
A typical way to use DynamoDB TTL, is to create a field (maybe name it as ExpirationTime) in you data object, add set it as (currentEpochTime + TimeToLive). After TimeToLive seconds, DynamoDB would find the value less than current EpochTime, and do the delete action (expect some delay).
Having said that, if you want to enable TTL after this table has been used by adding a new field to original data object. Existing data will not be affected as they do not have that field. You may want to run a script to add that new field value to all existing items to make TTL work for existing data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With