Creating and tailing a capped collection cursors in MongoDB
Capped collections are fixed size collections where documents are added towards the end of the collection, similar to a queue. As capped collection have a fixed size, older documents are removed if the limit is reached.
They are naturally sorted by the order of the insertion and any retrieval needed on them required ordered by time can be retrieved using the $natural
sort order. This makes document retrieval very fast.
The following figure gives a pictorial representation of a capped collection of a size which is good enough to hold up to three documents of equal size (which is too small for any practical use, but good for understanding). As we can see in the image, the collection is similar to a circular queue where the oldest document is replaced by the newly added document should the collection become full. The tailable cursors are special types of cursors that tail the collection similar to a tail command in Unix. These cursors...