20

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 TTL value, instead of doing manually batch delete item.

Amit
  • 211
  • 1
  • 2
  • 6

4 Answers4

30

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.

Under Table Details

Manage 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())
- Java: System.currentTimeMillis() / 1000L
- JavaScript: Math.floor(Date.now() / 1000)

ManJan
  • 3,939
  • 3
  • 20
  • 22
7

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.

ManJan
  • 3,939
  • 3
  • 20
  • 22
yadutaf
  • 6,840
  • 1
  • 37
  • 48
0

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/

siya
  • 1
0

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.

Jun
  • 2,942
  • 5
  • 28
  • 50