Skip to content

Commit 317f6b1

Browse files
committed
feat: add cache checker
1 parent b79c271 commit 317f6b1

4 files changed

Lines changed: 59 additions & 2 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Frosh\Tools\Components\Health\Checker\PerformanceChecker;
4+
5+
use Frosh\Tools\Components\Health\Checker\CheckerInterface;
6+
use Frosh\Tools\Components\Health\HealthCollection;
7+
use Frosh\Tools\Components\Health\SettingsResult;
8+
use Shopware\Core\DevOps\Environment\EnvironmentHelper;
9+
use function sprintf;
10+
use function version_compare;
11+
12+
class FixCacheSetChecker implements CheckerInterface
13+
{
14+
protected string $shopwareVersion;
15+
16+
public function __construct(string $shopwareVersion)
17+
{
18+
$this->shopwareVersion = $shopwareVersion;
19+
}
20+
21+
public function collect(HealthCollection $collection): void
22+
{
23+
if (version_compare('6.4.11.0', $this->shopwareVersion, '>')) {
24+
return;
25+
}
26+
27+
$cacheId = (string) EnvironmentHelper::getVariable('SHOPWARE_CACHE_ID', '');
28+
29+
if ($cacheId === '') {
30+
$collection->add(
31+
SettingsResult::warning('frosh-tools.checker.fixCacheIdNotSet',
32+
'not set',
33+
'set',
34+
'https://developer.shopware.com/docs/guides/hosting/performance/performance-tweaks#cache-id'
35+
)
36+
);
37+
38+
return;
39+
}
40+
41+
$collection->add(
42+
SettingsResult::ok('frosh-tools.checker.fixCacheIdIsSet',
43+
sprintf('set (%s)', $cacheId),
44+
'set',
45+
)
46+
);
47+
}
48+
}

src/Resources/app/administration/src/module/frosh-tools/snippet/de-DE.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@
101101
"incrementStorageIsDB": "Increment storage sollte im optimal fall Redis verwenden oder deaktiviert sein",
102102
"incrementStorageIsNotDB": "Increment storage ist richtig konfiguriert",
103103
"queueIsDefault": "Die Message Queue in der Datenbank skaliert nicht gut mit mehreren Workern",
104-
"queueIsOk": "Die Message Queue ist richtig konfiguriert"
104+
"queueIsOk": "Die Message Queue ist richtig konfiguriert",
105+
"fixCacheIdNotSet": "Eine feste Cache-ID sollte konfiguriert sein, um diese nicht immer aus der Datenbank zu lesen",
106+
"fixCacheIdIsSet": "Eine feste Cache-ID ist konfiguriert"
105107
},
106108
"size": "Größe",
107109
"docs": "Dokumente",

src/Resources/app/administration/src/module/frosh-tools/snippet/en-GB.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@
101101
"incrementStorageIsDB": "Increment storage is heavily using the Storage. This feature should be disabled or Redis should be used",
102102
"incrementStorageIsNotDB": "Increment storage is correct configured",
103103
"queueIsDefault": "The default queue storage in database does not scale well with multiple workers",
104-
"queueIsOk": "Configured queue storage is ok for multiple workers"
104+
"queueIsOk": "Configured queue storage is ok for multiple workers",
105+
"fixCacheIdNotSet": "A fixed cache id should be set, so Shopware isn't loading it from Database on any request",
106+
"fixCacheIdIsSet": "A fixed cache id is set"
105107
},
106108
"size": "Size",
107109
"docs": "Documents",

src/Resources/config/services.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@
140140
<tag name="frosh_tools.performance_checker"/>
141141
</service>
142142

143+
<service id="Frosh\Tools\Components\Health\Checker\PerformanceChecker\FixCacheSetChecker">
144+
<argument>%kernel.shopware_version%</argument>
145+
<tag name="frosh_tools.performance_checker"/>
146+
</service>
147+
143148
<service id="Frosh\Tools\Components\Messenger\TaskLoggingMiddleware">
144149
<argument type="service" id="frosh_tools.logging.tasks"/>
145150
</service>

0 commit comments

Comments
 (0)