-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: check for RedisTagAwareAdapter in performance info
- Loading branch information
Showing
4 changed files
with
145 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
src/Components/Health/Checker/PerformanceChecker/RedisTagAwareChecker.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Frosh\Tools\Components\Health\Checker\PerformanceChecker; | ||
|
||
use Frosh\Tools\Components\CacheAdapter; | ||
use Frosh\Tools\Components\CacheRegistry; | ||
use Frosh\Tools\Components\Health\Checker\CheckerInterface; | ||
use Frosh\Tools\Components\Health\HealthCollection; | ||
use Frosh\Tools\Components\Health\SettingsResult; | ||
|
||
class RedisTagAwareChecker implements PerformanceCheckerInterface, CheckerInterface | ||
{ | ||
public function __construct( | ||
private readonly CacheRegistry $cacheRegistry | ||
) {} | ||
|
||
public function collect(HealthCollection $collection): void | ||
{ | ||
$httpCacheType = $this->cacheRegistry->get('cache.http')->getType(); | ||
|
||
if (!\str_starts_with($httpCacheType, CacheAdapter::TYPE_REDIS) | ||
|| \str_starts_with($httpCacheType, CacheAdapter::TYPE_REDIS_TAG_AWARE)) { | ||
return; | ||
} | ||
|
||
$collection->add( | ||
SettingsResult::warning( | ||
'redis-tag-aware', | ||
'Redis should be TagAware', | ||
CacheAdapter::TYPE_REDIS, | ||
CacheAdapter::TYPE_REDIS_TAG_AWARE, | ||
'https://developer.shopware.com/docs/guides/hosting/performance/caches.html#example-replace-some-cache-with-redis' | ||
) | ||
); | ||
|
||
|
||
} | ||
|
||
private function checkAssertActive(HealthCollection $collection, string $url): void | ||
{ | ||
$currentValue = $this->iniGetFailover('zend.assertions'); | ||
if ($currentValue !== '-1') { | ||
$collection->add( | ||
SettingsResult::warning( | ||
'zend.assertions', | ||
'PHP value zend.assertions', | ||
$currentValue, | ||
'-1', | ||
$url | ||
) | ||
); | ||
} | ||
} | ||
|
||
private function checkEnableFileOverride(HealthCollection $collection, string $url): void | ||
{ | ||
$currentValue = $this->iniGetFailover('opcache.enable_file_override'); | ||
if ($currentValue !== '1') { | ||
$collection->add( | ||
SettingsResult::warning( | ||
'php.opcache.enable_file_override', | ||
'PHP value opcache.enable_file_override', | ||
$currentValue, | ||
'1', | ||
$url | ||
) | ||
); | ||
} | ||
} | ||
|
||
private function checkInternedStringsBuffer(HealthCollection $collection, string $url): void | ||
{ | ||
$currentValue = $this->iniGetFailover('opcache.interned_strings_buffer'); | ||
if ((int) $currentValue < 20) { | ||
$collection->add( | ||
SettingsResult::warning( | ||
'php.opcache.interned_strings_buffer', | ||
'PHP value opcache.interned_strings_buffer', | ||
$currentValue, | ||
'min 20', | ||
$url | ||
) | ||
); | ||
} | ||
} | ||
|
||
private function checkZendDetectUnicode(HealthCollection $collection, string $url): void | ||
{ | ||
$currentValue = $this->iniGetFailover('zend.detect_unicode'); | ||
if ($currentValue !== '0') { | ||
$collection->add( | ||
SettingsResult::warning( | ||
'php.zend.detect_unicode', | ||
'PHP value zend.detect_unicode', | ||
$currentValue, | ||
'0', | ||
$url | ||
) | ||
); | ||
} | ||
} | ||
|
||
private function checkRealpathCacheTtl(HealthCollection $collection, string $url): void | ||
{ | ||
$currentValue = $this->iniGetFailover('realpath_cache_ttl'); | ||
if ((int) $currentValue < 3600) { | ||
$collection->add( | ||
SettingsResult::warning( | ||
'php.zend.realpath_cache_ttl', | ||
'PHP value realpath_cache_ttl', | ||
$currentValue, | ||
'min 3600', | ||
$url | ||
) | ||
); | ||
} | ||
} | ||
|
||
private function iniGetFailover(string $option): string | ||
{ | ||
$currentValue = \ini_get($option); | ||
if (\is_string($currentValue)) { | ||
return $currentValue; | ||
} | ||
|
||
return 'not set'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters