title: MongoDB cache collection in memory?
body: <p>I am using <code>mongoDB</code> to store a collection of polygons and use <code>$geoIntersects</code> queries to find in which polygon a specific point is.</p>
  
  <p>My <code>mongoose</code> <code>Schema</code> looks like this:</p>
  
  <pre><code>var LocationShema = mongoose.Schema({
      name: String,
      geo: {
          type: {
              type: String 
          },
          coordinates: []
      }
  });
  
  LocationShema.index({geo: '2dsphere'});
  
  module.exports = mongoose.model('Location', LocationShema);
  </code></pre>
  
  <p>So, each element is a polygon. I added the <code>2dsphere</code> index hoping that the queries would be faster and the entire collection would be stored in memory. Unfortunately it takes about <code>600ms</code> for ~20queries which is way too much for my use case.</p>
  
  <p>My queries look like this:</p>
  
  <pre><code>Location.find({
              geo: {
                  $geoIntersects: {
                      $geometry: {
                          type: 'Point',
                          coordinates: [pos.lng, pos.lat]
                      }
                  }
              }
   },...)
  </code></pre>
  
  <p>Is there anyway I can make this run faster? Can I force MongoDB to cache the entire collection in the database (as ther collection never changes). Is there any way I can <strong>check if the collection is actually stored in an in-memory cache</strong>?</p>
  
  <p>Also, are there any alternatives I can use (eg: a library or something) that allows for fast geo-spatial queries?</p>