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 apcu_cache_adapter:
2     class: Symfony\Component\Cache\Adapter\ApcuAdapter
3     arguments:
4         - "define_namespace"
5         - "86400"
6     tags:
7         - { name: cache.pool }

Thanks for reading

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