Skip to content
This repository was archived by the owner on Jan 8, 2024. It is now read-only.

Commit 5581feb

Browse files
committed
Improved data collector template
1 parent 356a064 commit 5581feb

File tree

2 files changed

+70
-23
lines changed

2 files changed

+70
-23
lines changed

DataCollector/CacheCollector.php

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ public function __construct(Cache $cache)
2727
}
2828

2929
/**
30-
* @param \Symfony\Component\HttpFoundation\Request $request
30+
* @param \Symfony\Component\HttpFoundation\Request $request
3131
* @param \Symfony\Component\HttpFoundation\Response $response
32-
* @param \Exception|null $exception
32+
* @param \Exception|null $exception
3333
*/
3434
public function collect(Request $request, Response $response, \Exception $exception = null)
3535
{
@@ -43,55 +43,81 @@ public function collect(Request $request, Response $response, \Exception $except
4343
if ($cache->getStats()->getSize()) {
4444
$size += $cache->getStats()->getSize();
4545
}
46-
$stats[$instanceName] = $cache->getStats();
47-
$instances[$instanceName] = [
46+
$stats[ $instanceName ] = $cache->getStats();
47+
$instances[ $instanceName ] = [
4848
'driverName' => $cache->getDriverName(),
49-
'driverConfig' => $cache->getConfig()
49+
'driverConfig' => $cache->getConfig(),
5050
];
51-
$driverUsed[$cache->getDriverName()] = get_class($cache);
51+
$driverUsed[ $cache->getDriverName() ] = get_class($cache);
5252
}
5353

5454
$this->data = [
5555
'driverUsed' => $driverUsed,
5656
'instances' => $instances,
5757
'stats' => $stats,
58-
'size' => $size,
58+
'size' => $size,
5959
'hits' => [
60-
'read' => (int) CacheManager::$ReadHits,
61-
'write' => (int) CacheManager::$WriteHits,
62-
]
60+
'read' => (int) CacheManager::$ReadHits,
61+
'write' => (int) CacheManager::$WriteHits,
62+
],
63+
'coreConfig' => [
64+
'namespacePath' => CacheManager::getNamespacePath()
65+
],
6366
];
6467
}
6568

69+
/**
70+
* @return mixed
71+
*/
6672
public function getStats()
6773
{
68-
return $this->data['stats'];
74+
return $this->data[ 'stats' ];
6975
}
7076

77+
/**
78+
* @return mixed
79+
*/
7180
public function getInstances()
7281
{
73-
return $this->data['instances'];
82+
return $this->data[ 'instances' ];
7483
}
7584

85+
/**
86+
* @return mixed
87+
*/
7688
public function getDriverUsed()
7789
{
78-
return $this->data['driverUsed'];
90+
return $this->data[ 'driverUsed' ];
7991
}
8092

93+
/**
94+
* @return mixed
95+
*/
8196
public function getHits()
8297
{
83-
return $this->data['hits'];
98+
return $this->data[ 'hits' ];
8499
}
85100

101+
/**
102+
* @return mixed
103+
*/
86104
public function getSize()
87105
{
88-
/**
89-
* @var $name
90-
* @var ExtendedCacheItemPoolInterface $cache
91-
*/
92-
return $this->data['size'];
106+
return $this->data[ 'size' ];
93107
}
94108

109+
/**
110+
* @return mixed
111+
*/
112+
public function getCoreConfig()
113+
{
114+
return $this->data[ 'coreConfig' ];
115+
}
116+
117+
118+
/**
119+
* @return string
120+
*/
95121
public function getName()
96122
{
97123
return 'phpfastcache';

Resources/views/data_collector/template.html.twig

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@
6262
<span class="label">Cache Instances</span>
6363
</div>
6464
<div class="metric">
65-
<span class="value"> {{ collector.driverUsed|length }}</span>
65+
<span class="value"> {{ collector.driverUsed|length }}</span>
6666
<span class="label">Drivers used</span>
6767
</div>
6868
<div class="metric">
69-
<span class="value"> {{ collector.hits.read }}</span>
69+
<span class="value"> {{ collector.hits.read }}</span>
7070
<span class="label">Read hits</span>
7171
</div>
7272
<div class="metric">
73-
<span class="value"> {{ collector.hits.write }}</span>
73+
<span class="value"> {{ collector.hits.write }}</span>
7474
<span class="label">Write hits</span>
7575
</div>
7676
</div>
@@ -85,7 +85,11 @@
8585
<tbody>
8686
<tr>
8787
<th>Driver Name</th>
88-
<td><strong>{{ collector.instances[name].driverName }}</strong> (<small><code>{{ collector.driverUsed[collector.instances[name].driverName] }}</code></small>)</td>
88+
<td><strong>{{ collector.instances[name].driverName }}</strong> (
89+
<small><code>{{ collector.driverUsed[collector.instances[name].driverName] }}</code>
90+
</small>
91+
)
92+
</td>
8993
</tr>
9094
<tr>
9195
<th>Driver Info</th>
@@ -113,4 +117,21 @@
113117
</div>
114118
{% endfor %}
115119
</div>
120+
<h2>PhpFastCache Core Config</h2>
121+
<table class="">
122+
<thead>
123+
<tr>
124+
<th class="key" scope="col">Key</th>
125+
<th scope="col">Value</th>
126+
</tr>
127+
</thead>
128+
<tbody>
129+
{% for key, value in collector.coreConfig %}
130+
<tr>
131+
<th>{{ key }}</th>
132+
<td>{{ value }}</td>
133+
</tr>
134+
{% endfor %}
135+
</tbody>
136+
</table>
116137
{% endblock %}

0 commit comments

Comments
 (0)