简体   繁体   中英

DynamoDB time to live per Item

I have a requirement to expire items with different time to live configuration. There are cases where items in table won't expire of certain cases as well. In Cassandra we can set time-to-live while writing at the record level. In DynamoDB I could only see the TimeToLive configuration at table level (I could be wrong too.) but not at item level.

  1. Is there a way to set TTL at item level while doing putItem or
  2. What are the best practices to delete records with minimal effect on the overall system?

If there is no possibility to set TTL at item level, i would like to fall back to second option.

DynamoDB can absolutely do this on the item level in the table. In the table level configurations is where you tell DynamoDB the name of the attribute that will contain the value for the TTL. This attribute name can be whatever you want. Then on each item you write to the table, you include an attribute named what you told DynamoDB to look for with the value in epoch time format in seconds. Once you do that, when that item's time comes, DynamoDB will lazy delete the item in 24-48 hours. Best of all, that delete is of no cost to you.

For more information on how to enable TTL go here . For more about how TTL works, go here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM