Skip to content

TagAware cache is not profiled in the profiler #34810

@rbaarsma

Description

@rbaarsma

Symfony version(s) affected: 4.4.1 (probably also 3.4 and 5.0)

Description
When using a cache adapter with tags: true, and typehinting this adapter with TagAwareCacheInterface instead of the CacheItemPoolInterface (PSR-6), and running on env=dev or env=test, the TraceableAdapter is not used, but instead the Symfony\Component\Cache\Adapter\TagAwareAdapter is injected.

Because of this, the subsequent cache changes are not profiled.

How to reproduce

framework:
    cache:
        pools:
            app.cache_pool:
                adapters:
                    - cache.adapter.array
                    - cache.adapter.apcu
                    - cache.adapter.redis
                tags: true
use Symfony\Contracts\Cache\TagAwareCacheInterface;

class TestController 
{
  /** @var TagAwareAdapterInterface */
  private $appCachePool;

  public function __construct(TagAwareCacheInterface $appCachePool) 
  {
    echo get_class($appCachePool); // outputs Symfony\Component\Cache\Adapter\TagAwareAdapter
    $this->cache = $appCachePool;
  }

  /** @Route("/test") */
  public function test()
  {
    // works, but not in profiler
    $this->cache->get('somkey', function (ItemInterface $item) {
        $item->tag('sometag');
        return true;
    });
    $this->cache->invalidateTags('sometag');
  }
}

Possible Solution

Additional context

See also #34800

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy