java 一个项目在 dynamodb 中的生存时间
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13344577/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Time to live of a item in dynamodb
提问by Amit
I am playing with amazon dynamodb no-sql database from past few days and wondering that if there is any feature time to live (TTL)of a item, so that when item reached at that value it automatically deleted from table as per the TTLvalue, instead of doing manually batch delete item.
过去几天我一直在使用 amazon dynamodb no-sql 数据库,想知道是否有任何项目的生存时间 (TTL),以便当项目达到该值时,它会根据TTL值自动从表中删除,而不是手动批量删除项目。
回答by ManJan
Yes, Amazon released the time to live (TTL) feature to DynamoDb in Feb 2017. You just have to go to DynamoDb on your console. Select your table. Then click Overviewand enable it there.
是的,亚马逊于 2017 年 2 月向 DynamoDb 发布了生存时间 (TTL) 功能。您只需在控制台上访问 DynamoDb。选择你的桌子。然后单击概览并在那里启用它。
The TTL attribute should be your column/attribute that would decide when the row should be expired/deleted.
TTL 属性应该是您的列/属性,它将决定该行何时过期/删除。
NOTE:The ttl attribute should be of number datatype(because DynamoDb doesn't support datetime data type). So it should be in EPOCHtime format.
注意:ttl 属性应该是数字数据类型(因为 DynamoDb 不支持日期时间数据类型)。所以它应该是EPOCH时间格式。
For example:
- Linux Terminal: date +%s
- Python: import time; long(time.time())
- Java: System.currentTimeMillis() / 1000L
- JavaScript: Math.floor(Date.now() / 1000)
例如:
- Linux 终端:date +%s
- Python:import time; long(time.time())
- Java:System.currentTimeMillis() / 1000L
- JavaScript:Math.floor(Date.now() / 1000)
回答by yadutaf
EDIT: AWS released DynamoDb TTL feature in Feb 2017.
编辑:AWS 于 2017 年 2 月发布了 DynamoDb TTL 功能。
Unfortunately, the answer is pretty short: No
不幸的是,答案很短:不
As a matter of fact, DynamoDB has been designed from the ground up for simplicity. No fancy features.
事实上,DynamoDB 是从头开始设计的。没有花哨的功能。
回答by siya
Yes, They have recently released this feature. Go through the documentation below https://aws.amazon.com/about-aws/whats-new/2017/02/amazon-dynamodb-now-supports-automatic-item-expiration-with-time-to-live-ttl/
是的,他们最近发布了这个功能。浏览以下文档 https://aws.amazon.com/about-aws/whats-new/2017/02/amazon-dynamodb-now-supports-automatic-item-expiration-with-time-to-live-ttl /
回答by Jun711
You can do it using AWS DynamoDB console like what is stated by Manjan's answer.
您可以使用 AWS DynamoDB 控制台来完成,就像Manjan's answer所说的那样。
If you prefer to use a command, you can also use AWS DynamoDB CLI command:
如果您更喜欢使用命令,也可以使用 AWS DynamoDB CLI 命令:
aws dynamodb update-time-to-live
--table-name demoTable
--time-to-live-specification Enabled=true,AttributeName=ttl
You can check out this articlefor more information.
您可以查看这篇文章以获取更多信息。