DynamoDB TTL 是否适用于预先存在的项目?
Does DynamoDB TTL work on pre-existing items?
我有一个 DynamoDB table,里面有很多项目。我已将 table 配置为使用属性 "expiration" 作为 TTL 属性。然后我在我的系统中引入了一个错误,我在其中保存了所有属性为 "expiry" 的项目(doh!)。
为了解决这个问题,我关闭了 table 上的 TTL 支持,然后使用属性 "expiry" 重新启用它。当所有过期的物品都消失时,应该会有一个惊天动地的爆炸声。没有。我等了 24 小时,以防 Dynamo 需要醒来并注意我的 table。没有惊天动地的kaboom(悲伤的火星人......)。
我现在想知道 table 中在正确属性上启用 TTL 之前存在的项目是否真的错过了 TTL 船并且将保留在那里直到手动删除。我错过了什么?有没有其他人遇到过这种情况?
是的,DynamoDB 应该删除过期的项目,即使它们是在选择 TTL 列之前创建的。至少,文档中没有任何其他建议。 documentation 解释 TTL 的工作原理:
DynamoDB compares the current time, in epoch time format, to the value stored in the user-defined Number attribute of an item. If the attribute’s value is in the epoch time format, is less than the current time, and is not older than 5 years, the item is deleted. Processing takes place automatically, in the background.
你说你等了 24 小时才删除。也许这还不够,因为同一份文件还说:
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.
现在 48 小时过去了,请您再检查一下好吗?
更新(基于上面的讨论):
如果 TTL 功能似乎不起作用,您应该确保正确设置了 TTL 属性。首先确保您使用正确的名称设置属性(这是提问者的第一个问题)。然后,您应该确保在此属性中设置一个 integer 值(它不能是字符串!)。最后确保这个整数是自纪元(格林威治标准时间午夜,1970 年 1 月 1 日午夜)以来的秒数 - 提问者不小心在这里使用了毫秒而不是秒,所以它没有起作用。
我有一个 DynamoDB table,里面有很多项目。我已将 table 配置为使用属性 "expiration" 作为 TTL 属性。然后我在我的系统中引入了一个错误,我在其中保存了所有属性为 "expiry" 的项目(doh!)。
为了解决这个问题,我关闭了 table 上的 TTL 支持,然后使用属性 "expiry" 重新启用它。当所有过期的物品都消失时,应该会有一个惊天动地的爆炸声。没有。我等了 24 小时,以防 Dynamo 需要醒来并注意我的 table。没有惊天动地的kaboom(悲伤的火星人......)。
我现在想知道 table 中在正确属性上启用 TTL 之前存在的项目是否真的错过了 TTL 船并且将保留在那里直到手动删除。我错过了什么?有没有其他人遇到过这种情况?
是的,DynamoDB 应该删除过期的项目,即使它们是在选择 TTL 列之前创建的。至少,文档中没有任何其他建议。 documentation 解释 TTL 的工作原理:
DynamoDB compares the current time, in epoch time format, to the value stored in the user-defined Number attribute of an item. If the attribute’s value is in the epoch time format, is less than the current time, and is not older than 5 years, the item is deleted. Processing takes place automatically, in the background.
你说你等了 24 小时才删除。也许这还不够,因为同一份文件还说:
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.
现在 48 小时过去了,请您再检查一下好吗?
更新(基于上面的讨论): 如果 TTL 功能似乎不起作用,您应该确保正确设置了 TTL 属性。首先确保您使用正确的名称设置属性(这是提问者的第一个问题)。然后,您应该确保在此属性中设置一个 integer 值(它不能是字符串!)。最后确保这个整数是自纪元(格林威治标准时间午夜,1970 年 1 月 1 日午夜)以来的秒数 - 提问者不小心在这里使用了毫秒而不是秒,所以它没有起作用。