mongodb TTL不删除文档
Posted
技术标签:
??????mongodb TTL???????????:mongodb TTL not removing documents ??????:2013-09-14 16:24:57 ??????:?????????,??:
_id: String, // auto generated
key: String, // there is a unique index on this field
timestamp: Date() // set to current time
???????? TTL ??:
db.sess.ensureIndex( "timestamp": 1 , expireAfterSeconds: 3600 )
??????? 1 ??????,?????????? ??????????,??? TTLMonitor ????:
Tue Sep 10 10:42:37.081 [TTLMonitor] TTL: timestamp: 1.0 timestamp: $lt: new Date(1378823557081)
Tue Sep 10 10:42:37.081 [TTLMonitor] TTL deleted: 0
??????????,??????????????:
db.sess.find( timestamp: $lt: new Date(1378823557081) )
...
?????????????
?? - ???????
"_id" : "3971446b45e640fdb30ebb3d58663807", "key" : "6XTHYKG7XBTQE9MJH8", "timestamp" : ISODate("2013-09-09T18:54:28Z")
??????:
?????1?:??????: ????????????:
"v" : 1,
"key" :
"columnName" : 1,
"expireAfterSeconds" : 172800
,
"name" : "columnName_1_expireAfterSeconds_172800",
"ns" : "dbName.collectionName"
??????????:(expireAfterSeconds ?***??)
"v" : 1,
"key" :
"columnName" : 1
,
"expireAfterSeconds" : 172800,
"name" : "columnName_1_expireAfterSeconds_172800",
"ns" : "dbName.collectionName"
????:
?????2?:?????????????????????
“??”??????????????:
??:TTL ???????????????????? MongoDB ?????????????????????
????????????
????:
TTLMonitor ? 60 ?????,?????????????? 1 ????????????????(??,?????,????????)??? 2 ???——?????????? TTL ???????????????????????? ?,????????db.sess.find().pretty()
??????——????????????????????????????,?????db.sess.getIndexes()
???????????
db.sess.getIndexes()
?????????????????db['system.indexes'].find(expireAfterSeconds: $ne: null)
——??????????????????,??system.indexes
?????????????????????!
????? Node.js mongoose,????????????????????????,?????????????
@huggie ????????????????以上是关于mongodb TTL不删除文档的主要内容,如果未能解决你的问题,请参考以下文章