简体   繁体   中英

Time to live of a item in dynamodb

我正在玩amazon dynamodb no-sql数据库,过去几天,并想知道如果有一个项目的任何功能生存时间(TTL) ,那么当项目达到该值时,它会根据TTL值自动从表中删除而不是手动批量删除项目。

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 Overview and enable it there.

在表详细信息下

管理TTL

The TTL attribute should be your column/attribute that would decide when the row should be expired/deleted.

NOTE: The ttl attribute should be of number datatype(because DynamoDb doesn't support datetime data type). So it should be in EPOCH time format.

For example:
- Linux Terminal: date +%s
- Python: import time; long(time.time()) import time; long(time.time())
- Java: System.currentTimeMillis() / 1000L
- JavaScript: Math.floor(Date.now() / 1000)

EDIT: AWS released DynamoDb TTL feature in Feb 2017.

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.

You can do it using AWS DynamoDB console like what is stated by Manjan's answer .

If you prefer to use a command, you can also use AWS DynamoDB CLI command:

aws dynamodb update-time-to-live
--table-name demoTable
--time-to-live-specification Enabled=true,AttributeName=ttl

You can check out this article for more information.

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