Twig icon indicating copy to clipboard operation
Twig copied to clipboard

Cache tags don't work in Symfony when @cache.app is TagAware

Open rpkamp opened this issue 2 years ago • 0 comments

I wanted to create this issue in the twig-extra-bundle repository, but since issues seem to be disable there I'll create it here.

The problem I encountered is that twig-cache doesn't work in Symfony when @cache.app is TagAware, because the TwigExtraBundle wraps @cache.app with a TagAwareCacheAdapter, so the cache is tag aware twice to say. Which doesn't work at all, and causes every read to be a MISS.

Making @cache.app not TagAware solves the problem, but ideally I didn't want to have to that.

I can see multiple solutions:

  1. At least document this so people are aware
  2. Check if @app.cache is TagAware and if so behave differently
  3. Allow configuration for what cache should be injected instead of always using @cache.app

rpkamp avatar Aug 10 '23 15:08 rpkamp