0
MongoDb 2.0.7。 也就是說日期的聲明方式在C#中存儲的對象爲MyObject:Mongo的生存時間(TTL)索引對我無效
public class MyObject
{
[BsonDateTimeOptions(Kind = DateTimeKind.Local)]
public DateTime Created { get; set; }
...
}
也就是說指數是如何創建的:
Collection.EnsureIndex(new IndexKeysBuilder<MyObject>().Ascending(l => l.Created), IndexOptions.SetName("CreatedDateIndex").SetTimeToLive(new TimeSpan(0, 0, 60)));
MongoVUE
工具確認命名CreatedDateIndex
指數收集MyObject
創建了expireAfterSeconds = 60
。 Created
字段沒有更多索引。
但是集合中的項目是永遠不會自動刪除,我還在這裏看到幾天老項目,如本文件:
{
"_id" : new BinData(3, "OVdRaIodPUKz7cCuaxnFpA=="),
"Created" : ISODate("2014-01-09T23:41:08.732Z"),
}
可能是什麼問題?我只能猜測錯誤是數據類型,可能不是Bson日期類型,它甚至不會警告我,反正我甚至不知道如何驗證它。