iSm*_*Smo 5 spring mongodb mongodb-indexes spring-boot spring-mongodb
我对 MongoDB 中的“生存时间”设置有疑问。我在我的实体中的 Spring-Boot 2.0.2.RELEASE 项目中创建了一个索引注释,它代表我在 MongoDB 中的文档。我将测试的“expireAfterSeconds”设置为 15 秒,但 MongoDB 在 15 秒后不会删除插入的文档。有人能告诉我我做错了什么吗?
这是 JSON 形式的 MongoDB 索引:
[
2,
{
"createdDateTime" : 1
},
"deleteAt",
"AccountServiceDB.AccountRegistration",
NumberLong(15)
]
Run Code Online (Sandbox Code Playgroud)
这是我的实体:
@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;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2003 次 |
| 最近记录: |