title: Generic cache of objects
body: <p>Does anyone know any implementation of a templated cache of objects?</p>
  
  <ul>
  <li>You use a key to find object (the same as in std::map&lt;>)</li>
  <li>You specify a maximum number of objects that can be in the cache at the same time</li>
  <li>There are facilities to create an object not found in the cache</li>
  <li>There are facilities to know when an object is discarded from the cache</li>
  </ul>
  
  <p>For example : </p>
  
  <pre><code>typedef cache&lt;int, MyObj*&gt; MyCache;
  MyCache oCache;
  oCache.SetSize(1);
  oCache.Insert(make_pair(1, new MyObj());
  oCache.Touch(1);
  MyObj* oldObj = oCache.Delete(1);
  
  ...
  </code></pre>
  
  <p>It can be as simple as a LRU or MRU cache.</p>
  
  <p>Any suggestions are welcomed!</p>
  
  <p>Nic</p>