diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig index b2f06be8c5f3b..0ad6c85df08b6 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig @@ -97,6 +97,14 @@

{{ name }} {{ collector.statistics[name].calls }}

+

Adapter

+
+ {% if collector.adapters[name] is defined %} + {{ collector.adapters[name] }} + {% else %} + Unable to get adapter class. + {% endif %} +
{% if calls|length == 0 %}

No calls were made for {{ name }} pool.

diff --git a/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php b/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php index 0b577aa0af64b..7c4c9ce9aea29 100644 --- a/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php @@ -260,6 +260,11 @@ public function clearCalls() $this->calls = []; } + public function getPool(): AdapterInterface + { + return $this->pool; + } + protected function start(string $name) { $this->calls[] = $event = new TraceableAdapterEvent(); diff --git a/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php b/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php index 4fb700bb66fd3..e7dbb641f0cdb 100644 --- a/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php +++ b/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php @@ -41,10 +41,11 @@ public function addInstance(string $name, TraceableAdapter $instance) */ public function collect(Request $request, Response $response, \Throwable $exception = null) { - $empty = ['calls' => [], 'config' => [], 'options' => [], 'statistics' => []]; + $empty = ['calls' => [], 'adapters' => [], 'config' => [], 'options' => [], 'statistics' => []]; $this->data = ['instances' => $empty, 'total' => $empty]; foreach ($this->instances as $name => $instance) { $this->data['instances']['calls'][$name] = $instance->getCalls(); + $this->data['instances']['adapters'][$name] = \get_debug_type($instance->getPool()); } $this->data['instances']['statistics'] = $this->calculateStatistics(); @@ -96,6 +97,14 @@ public function getCalls(): mixed return $this->data['instances']['calls']; } + /** + * Method returns all logged Cache adapter classes. + */ + public function getAdapters(): array + { + return $this->data['instances']['adapters']; + } + private function calculateStatistics(): array { $statistics = [];