title: understand MongoDB cache system
body: <p>This is a basic question, but very important, and i am not sure to really get the point.</p>
  
  <p>On the official documentation we can read </p>
  
  <blockquote>
    <p>MongoDB keeps all of the most recently used data in RAM. If you have created indexes for your queries and your working data set fits in RAM, MongoDB serves all queries from memory.</p>
  </blockquote>
  
  <p>The part i am not sure to understand is </p>
  
  <blockquote>
    <p>If you have created indexes for your queries and your working data set fits in RAM</p>
  </blockquote>
  
  <p>what does mean "indexes" here?</p>
  
  <p>For example, if i update a model, then i query it, because i have updated it, it's now in RAM so it will come from the memory, but this is not very clear in my mind. </p>
  
  <p>How can we be sure that datas we query will come from the memory or not? I understand that MongoDB uses the free memory to cache datas about the memory which is free on the moment, but does someone could explain further the global behavior ?</p>
  
  <p>In which case could it be better to use a variable in our node server which store datas than trust the MongoDB cache system?</p>
  
  <p>How do you globally advise to use MongoDB for huge traffic?</p>