简体   繁体   English

DynamoDB每个项目的生存时间

[英]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. 在Cassandra中,我们可以设置记录时间的生存时间。 In DynamoDB I could only see the TimeToLive configuration at table level (I could be wrong too.) but not at item level. 在DynamoDB中,我只能在表级别看到TimeToLive配置(我也可能错了。),但在项目级别却看不到。

  1. Is there a way to set TTL at item level while doing putItem or 在执行putItem时是否可以在项目级别设置TTL或
  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. 如果无法在项目级别设置TTL,我想退回到第二个选项。

DynamoDB can absolutely do this on the item level in the table. DynamoDB绝对可以在表中的项目级别执行此操作。 In the table level configurations is where you tell DynamoDB the name of the attribute that will contain the value for the TTL. 在表级别配置中,您可以在其中告诉DynamoDB名称属性,该属性名称将包含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. 然后,在您写入表的每个项目上,都包含一个名为DynamoDB的属性,该属性告诉DynamoDB以纪元时间格式(以秒为单位)查找值。 Once you do that, when that item's time comes, DynamoDB will lazy delete the item in 24-48 hours. 完成此操作后,当该项目的时间到来时,DynamoDB将在24-48小时内延迟删除该项目。 Best of all, that delete is of no cost to you. 最重要的是,删除对您来说是免费的。

For more information on how to enable TTL go here . 有关如何启用TTL的更多信息, 请转到此处 For more about how TTL works, go here . 有关TTL如何工作的更多信息, 请转到此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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