title: Delete dynamic-generated cache entries on Doctrine
body: <p>I am using doctrine's result cache to improve my application performance. I am using dynamic ids because that info comes from the user. I'd like to flush all cache ids related to this entity (PortfolioFunds) but I don't know those dynamic-generated ids:</p>
  <pre><code>class PostgresqlFundsRepository 
  {
      // ...   
      
      public function save(PortfolioFunds $portfolioFunds): void
      {
          $this-&gt;em-&gt;persist($portfolioFunds);
          $this-&gt;em-&gt;flush();
          $this-&gt;deleteCacheId($portfolioFunds-&gt;portfolioId());
      }
  
      public function fetchByPortfolioId(PortfolioId $portfolioId): array
      {
          return $this-&gt;createQueryBuilder('f')
              -&gt;where('f.portfolioId = :portfolioId')
              -&gt;setParameter('portfolioId', $portfolioId)
              -&gt;getQuery()
              -&gt;useQueryCache(true)
              -&gt;enableResultCache()
              -&gt;setResultCacheId($this-&gt;cacheId($portfolioId))
              -&gt;getArrayResult();
      }
  
      public function findByPortfolioIdAndCurrency(
          PortfolioId $portfolioId,
          Currency $currency
      ): ?PortfolioFunds {
  
          $query = $this-&gt;createQueryBuilder('f')
              -&gt;where('f.portfolioId = :portfolioId')
              -&gt;andWhere('f.money LIKE :money')
              -&gt;setParameter('portfolioId', $portfolioId)
              -&gt;setParameter('money', '%' . $currency)
              -&gt;getQuery()
              -&gt;useQueryCache(true)
              -&gt;enableResultCache()
              -&gt;setResultCacheId($this-&gt;cacheId($portfolioId, $currency));
  
          return $query-&gt;getOneOrNullResult();
      }
  
  
      private function cacheId(PortfolioId $id, ?Currency $currency = null): string
      {
          return sprintf('portfolio_%s_funds_%s', $id, $currency);
      }
  
      private function deleteCacheId(PortfolioId $id): void
      {
          $this-&gt;em-&gt;getConfiguration()-&gt;getResultCacheImpl()-&gt;delete(
              $this-&gt;cacheId($id)
          );
  
          // HERE I'd like to delete ids that contain currencies as well
      }
  
  }
  </code></pre>
  <p>Is there anything like namespaces or something that I can use?</p>
  <p>I am using Symfony 5.3, PHP 7 and Memcached</p>