I have a problem with the "time to live" settings in MongoDB. I created an Indexed Annotation in my Spring-Boot 2.0.2.RELEASE project in my Entity which represents my Document in the MongoDB. I set the "expireAfterSeconds" for testing to 15 seconds but MongoDB does not delete a inserted Document after 15 seconds. Can someone tell me what I'm doing wrong?
This is the MongoDB Index as JSON:
[
2,
{
"createdDateTime" : 1
},
"deleteAt",
"AccountServiceDB.AccountRegistration",
NumberLong(15)
]
This is my entity:
@Document(collection = "AccountRegistration")
public class UserRegistration {
@Id
private ObjectId _id;
@Indexed(unique = true)
private String username;
@Indexed(unique = true)
private String email;
private String user_password;
@Indexed(name = "deleteAt", expireAfterSeconds = 15)
private Date createdDateTime;
public UserRegistration() {}
public ObjectId get_id() {
return _id;
}
public void set_id(ObjectId _id) {
this._id = _id;
}
}