They are two different things. MongoDB uses a simple swap memory management system, which by design stores the most accessible part of the disk space with memory in memory.
As a result, this will help you the most for counters, which are often requested but not often changed. Unfortunately, for website counters, these two things are mutually exclusive. Since increasing counters generally does not cause MongoDB to move the document containing the counter on disk, reading caching will still be quite efficient.
The main problem is that what you write, basically making an increase per visit, will not be very cost effective. I suggest a strategy in which your webapp counter caches incoming visits and only pushes update counts every X visits or every Y seconds, whichever comes first. Your main goal here is to reduce the number of records per second, so you definitely do not need to write db to the hit counter.
source share