title: Symfony entity changed and persisted by another process. My long-running process doesn't detect it
body: <p>I have a long running symfony process that queries entities regularly using</p>
  
  <pre><code> $msg = $this-&gt;entityManager-&gt;getRepository('App\Entity\Message')-&gt;findOneBy([
          'id' =&gt; $id
      ]);
  </code></pre>
  
  <p>I get the message and all is fine.Two minutes later the same message is changed and persisted by another Symfony process. Now 5 minutes later I again query the same msg Id:</p>
  
  <pre><code> $msg = $this-&gt;entityManager-&gt;getRepository('App\Entity\Message')-&gt;findOneBy([
          'id' =&gt; $id
      ]);
  </code></pre>
  
  <p>Unfortunately 
  I again get the original message, probably because it is cached, i.e. Symfony/Doctrine didn't detect that the other process had modified the database
  <br><br>I can of course do </p>
  
  <pre><code>$this-&gt;entityManager-&gt;refresh($msg);
  </code></pre>
  
  <p>, but that would cause a lot of unnecessary load on the database.
  <br><br>
  Is there a better way, e.g. setting a general timeToLive for the cache? Or even better: have Symfony detect when the cache gets "dirty"?</p>