title: Python: building an LRU cache
body: <p>I have around <code>6,00,000 entries in MongoDB</code> in the following format:   </p>
  
  <pre><code>feature:category:count
  </code></pre>
  
  <p>where </p>
  
  <ul>
  <li><strong>feature</strong> could be any word, </li>
  <li><strong>category</strong> is positive or negative, and </li>
  <li><strong>count</strong> tells how many times a feature occurred in a document for that category.   </li>
  </ul>
  
  <p>I want to cache the top 1000 tuples, let's say so as not to query database each time.  </p>
  
  <p>How does one build an LRU cache in Python?  Or are there any known solutions to this?</p>