title: Doctrine - Break query cache when entity is modified (second-level cache)
body: <p>I'm using doctrine 2 without caching anything at the moment. I'd like to enable some caching system within Doctrine but it looks like you have to manage it manually everywhere:</p>
  
  <pre><code>$memcache = new Memcache();
  $memcache-&gt;connect('memcache_host', 11211);
  
  $cacheDriver = new \Doctrine\Common\Cache\MemcacheCache();
  $cacheDriver-&gt;setMemcache($memcache);
  $cacheDriver-&gt;save('cache_id', 'my_data');
  ...
  $cacheDriver-&gt;delete('cache_id');
  </code></pre>
  
  <p>I'd like to know if Doctrine could manage this automatically. For instance:</p>
  
  <ol>
  <li><p>The cache is enable, I request a <code>User</code> entity by id, Doctrine search in its cache, cannot find the user, fetch it, set it into the cache, return it. </p></li>
  <li><p>I fetch a second time, Doctrine return me the cached <code>User</code>.</p></li>
  <li>I update the <code>User</code> (or any of its relations) Doctrine detect it and break the cache for this object</li>
  <li>I request the same <code>User</code> by id, Doctrine doesn't have it in cache anymore, fetch it and set the cache back with the updated user before to return it</li>
  </ol>
  
  <p>Is that possible?</p>
  
  <p>Cheers, 
  Maxime</p>