Joeri Verdeyen bio photo

Joeri Verdeyen

Web-engineer, cyclist, Nespresso lover, Strava pusher.

Twitter LinkedIn Instagram Github Stackoverflow Last.fm Strava

Collect CacheAdapter stats in Symfony Profiler

The Symfony community added a cache data collector and profiler page since the 3.3.0 release. Which is a very nice feature to debug cache hits and misses.

Tagged CacheAdapters

By default it only collects data from CacheAdapters tagged with cache.pool. These Symfony CacheAdapters are already tagged:

  • cache.app
  • cache.system
  • cache.validator
  • cache.serializer
  • cache.annotations

Collect your own CacheAdapter stats

It’s easy to add your own CacheAdapter to collect stats in the Symfony Profiler. The following snippet adds a ApcuAdapter to the Symfony Profiler.

1
2
3
4
5
6
7
apcu_cache_adapter:
    class: Symfony\Component\Cache\Adapter\ApcuAdapter
    arguments:
        - "define_namespace"
        - "86400"
    tags:
        - { name: cache.pool }

Thanks for reading

Feel free to leave a comment if you have remarks or like this post