MongoDB - Capturing Dropped Objects From A Capped Collection
Quoting from the MongoDB docs on Capped Collections:
Once the space is fully utilized, newly added objects will replace the oldest objects in the collection.
Is there any way to capture a capped collection's "dropped" objects before they are overwritten 开发者_Go百科? What I am interested in doing is implementing a series of rollup collections. eg.
Hourly --> Daily --> Weekly --> Monthly etc.
so when an object is dropped from the Hourly collections, I want to capture it and aggregate it up to the Daily collection.
Thanks in advance.
//Nicholas
You would have to implement that functionality in code rather than in MongoDB.
I don't think Capped Collections are the right solution for your use-case.
You could insert into a capped collection, and at the same time insert into a "normal" collection, and aggregate them into hourly / daily, weekly, monthly etc... using map reduce.
As per the MongoDB developers, you can't do this:
http://groups.google.com/group/mongodb-user/browse_thread/thread/aec8d0c85f58d89e/d6701df083eb4679?fwc=1
What I am interested in doing is implementing a series of rollup collections.
As alex said, one way to solve this is to use MapReduce. Another way is to have a different collection e.g. per day, for example logs20110414 and have your application manage read/writes to the appropriate collection.
精彩评论