Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Time to live of a item in dynamodb

Tags:

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.

like image 903
Amit Avatar asked Nov 12 '12 13:11

Amit


People also ask

Is DynamoDB TTL in milliseconds?

Note: Be sure that the timestamp is in seconds, not milliseconds (for example, use 1572268323 instead of 1572268323000).

How do I add TTL to DynamoDB table?

Sign in to the AWS Management Console and open the DynamoDB console at https://console.aws.amazon.com/dynamodb/ . Choose Tables, and then choose the table that you want to modify. In the Additional settings tab, in the Time to Live (TTL) section, choose Enable.

Can you update TTL in DynamoDB?

Yes, it will delay the expiration. The key statement, as you pointed out, is at How It Works: DynamoDB Time to Live (TTL): Items that are past their expiration, but have not yet been deleted can still be updated, and successful updates to change or remove the expiration attribute will be honored.

Is DynamoDB TTL reliable?

TTL precisionDynamoDB 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.


1 Answers

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)

like image 84
ManJan Avatar answered Oct 07 '22 11:10

ManJan