我在集合created_at字段上創(chuàng)建了一個 TTL 索引,以便在 30 秒后自動刪除文檔,但過了一段時間(5 分鐘后),文檔并未被刪除。我讀了一些相關(guān)的問題,我確信我的收藏中沒有錯字。這是運(yùn)行后的 JSONdb[collectionName].getIndexes()[{ "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "record_db.collectionName"},{ "v" : 2, "key" : { "created_at" : 1.0 }, "name" : "created_at_1", "ns" : "record_db.collectionName", "expireAfterSeconds" : 30.0}] 這是一個示例文檔:{ "_id" : ObjectId("5fc3823af29f9d9eb1518857"), "record_path" : path/to/file, "timestamp" : 1606648392, "humantime" : "29/11/2020 18:12:58", "created_at" : ISODate("2020-11-29T18:12:58.859Z")}
MongoDB TTL索引不會刪除過期記錄
呼喚遠(yuǎn)方
2023-09-14 20:40:53