TTL Index
Using Time-To-Live Index to automatically deleting entities.
Imagine you have an entity, which should be deleted after a specific time. Instead of creating a repeated task in java through a Timer
or an ScheduledExecutorService
and using the resources of the application, en2do offers to use MongoDBs time-to-live indexes.
First of all you need to create at least one field of the type java.util.Date
in your entity.
After that you can decide between two TTLIndex
options:
Delete at timeStamp =
{ttl} {unit} + {timeStamp of field}
Delete at timeStamp =
{timeStamp of field}
Example of both time-to-live indexes:
Last updated