Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TagAware cache is not profiled in the profiler #34810

Closed
rbaarsma opened this issue Dec 4, 2019 · 2 comments
Closed

TagAware cache is not profiled in the profiler #34810

rbaarsma opened this issue Dec 4, 2019 · 2 comments
Labels
Bug Cache Help wanted Issues and PRs which are looking for volunteers to complete them. Status: Needs Review

Comments

@rbaarsma
Copy link
Contributor

rbaarsma commented Dec 4, 2019

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

@nicolas-grekas
Copy link
Member

Good catch. Would you be able to send a PR to fix the wiring?

@chalasr chalasr added the Help wanted Issues and PRs which are looking for volunteers to complete them. label Dec 30, 2019
@nicolas-grekas
Copy link
Member

Fixed by #36536?

nicolas-grekas added a commit that referenced this issue Apr 26, 2020
…llector (l-vo)

This PR was merged into the 4.4 branch.

Discussion
----------

[Cache] Allow invalidateTags calls to be traced by data collector

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | #34810
| License       | MIT
| Doc PR        |

`TraceableTagAwareAdapter` is not used in the fullstack framework since tag aware pools don't have the `cache.pool` tag (it's the decorated adapter that has it). This PR aims to use `TraceableTagAwareAdapter` when a pool is configured with `tags: true`

Commits
-------

28fdb3a Allow invalidateTags calls to be traced by data collector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Cache Help wanted Issues and PRs which are looking for volunteers to complete them. Status: Needs Review
Projects
None yet
Development

No branches or pull requests

5 participants