I am trying to test MongoDB TTL functionality for short-lived collections. Using @Indexed annotation on field like this:
@Indexed(name = "deleteAt", expireAfterSeconds = 5)
private Date deleteAt;
In constructor I initialise deleteAt to this.deleteAt = new Date() and I expect after inserting my Document to Mongo that after it's TTLManager will run this collection will be removed. But It is not being removed even waiting for a few minutes doesn't help. I ran db.serverStatus().metrics.ttl in mongo shell and it returned:
[
{
"deletedDocuments": 0,
"passes": 8
}
]
And command db.adminCommand({getParameter:1, ttlMonitorEnabled: 1}) returns:
[
{
"ok": 1,
"ttlMonitorEnabled": true
}
]
Is something wrong with my code ? Or it is because of embedded mongo doesn't support this, is it possible to configure embedded mongo so it would work ? I am using https://github.com/flapdoodle-oss/de.flapdoodle.embed.mongo for embedded MongoDB with default settings.