Reputation: 10412
Mongo isn't expiring old collections. I checked to make sure my index is type date.
var keys = IndexKeys.Ascending("expiry");
var options = IndexOptions.SetTimeToLive(TimeSpan.FromMinutes(1));
collection.EnsureIndex(keys, options);
this.ExpireDate = new BsonDateTime(DateTime.UtcNow.AddMinutes(5));
var insertResult = collection.Insert(this);
Any tips would be gladly appreciated.
[
{
"v" : 1,
"key" : {
"_id" : 1
},
"ns" : "Showsv1.ShowInfo",
"name" : "_id_"
},
{
"v" : 1,
"key" : {
"expiry" : 1
},
"ns" : "Showsv1.ShowInfo",
"name" : "expiry_1",
"expireAfterSeconds" : 60
}
]
"expiry" : ISODate("2013-02-15T02:40:45.876Z")
Upvotes: 4
Views: 5016
Reputation: 10412
The code was missing [BsonElement("expiry")] on top of the ExpireTime property. Thanks @WiredPrairie for the tip.
Upvotes: 2