1, overview
A set of restrictions is a special set in MongoDB; his size is fixed, the storage rules follow the fisrt-in-fisrt-out FIFO principle!
2, judging/creating/converting
Determines whether the set belongs to the restricted set db.collection.isCapped ();
Restricted collections must be created manually, cut to the specified size! (Other collections do not have to be created manually) db.createcollection ("log", {capped:true,size:1024,max:500}); Capped Description collection type size specified collection physical size max Limit number of document bars
Normal collection converted to restriction set: Db.runcommand ({"converttocapped": "Mycoll", size:100000});
3, add data/Update data
The limit set adds data, and if the limit set size is exceeded, the first entry to the document is deleted and written to the new document;
Update data: You can do a document in-place update. If this update operation causes the document to grow beyond their original size, the update operation will fail. If you plan to update the document in a restricted set, create an index so that the update operation does not require a table-level scan
Fragment related post-supplement;
Mongodb_ limit Set (Capped)