springmongodbspring-bootindexed

Would like to delete a document after 30 min , stuck at the moment


I am using the indexed expire after second ,everything seems fine for me ,but nothing happens after 30 seconds is there more I should do or am I doing something wrong

public class ConfirmationToken {
    @Id
    private String tokenid;

    private String confirmationToken;

    @Field
    @Indexed(name="createdDate", expireAfterSeconds=3600)
    private Date createdDate;

    private Entity user;
    
    public ConfirmationToken() {
    }
    
    public ConfirmationToken(Entity user) {
        this.user = user;
        createdDate = new Date();
        confirmationToken = UUID.randomUUID().toString();
    }




 // Getters and Setter
}

Solution

  • Your TTL index is based on 60 minutes (3600 seconds).

    And the documents are casually deleted, which means they won't be deleted at that exact moment. But any time after that when database is not very busy.