title: Limit the number of documents in a collection in mongodb
body: <p>I have a collection that use as a cache. How can I limit the documents number to 5M inside this collection.
  Note: that the cache item can be updated will existing in the cache.
  I use tried to use capped, but the item saves in a capped collection cannot be modified.</p>
  
  <p>Is there a way to do that?
  (i would like to avoid delete the item and then insert the update one)</p>