DynamoDB 上的 TTL 功能是否可以用作实际删除项目的免费替代方案?

Can the TTL feature on DynamoDB be used as a free alternative to actually deleting items?

我已经阅读了使用 DynamoDB TTL 使项目过期的开发人员指南,并且想知道是否可以使用 TTL 作为删除的替代方法,而不是补充。

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/TTL.html

由于 Amazon 会在不消耗任何写入单元的情况下为您删除商品(在他们方便的时候),是否可以像这样完成我的所有删除操作?这个想法是创建没有 TTL 的项目,然后将 TTL 设置为当前时间而不是删除它们。我知道我必须添加一些逻辑来说明过期但未删除的项目,但这与节省的费用相比似乎微不足道。

这可能吗?

您是正确的,项目本身将被删除,您无需支付任何费用,这确实使删除项目的过程免费。

从 TTL 时间开始,删除过程最多可能需要 48 小时(项目作为后台操作排队),因此您需要确保您的应用程序执行过滤掉这些项目的逻辑。

Depending on the size and activity level of a table, the actual delete operation of an expired item can vary. Because TTL is meant to be a background process, the nature of the capacity used to expire and delete items via TTL is variable (but free of charge). TTL typically deletes expired items within 48 hours of expiration.

除非您有大量数据deleting/updating,否则您将只使用 DynamoDB table 剩余的任何可用 WCU。

The idea would be to create items without a TTL, and then instead of deleting them just setting the TTL to the current time.

这没有意义,您需要使用 WCU 来更新项目,还不如删除它。

当您可以在创建项目时设置 TTL 时,使用 TTL 免费删除项目是有意义的。

我想如果您有多个 GSI,使用更新设置 TTL 可能会有用。您只需为 table 的更新付费,删除是免费的。而如果您删除 table 中的记录,则需要为 table 和 GSI 付费。