From: Tim Düsterhus Date: Wed, 2 Mar 2022 15:24:59 +0000 (+0100) Subject: Make CacheHandler::getCacheName() less expensive X-Git-Tag: 5.5.0_Alpha_1~99^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=74efd48f6fd55577246386802ad86490179cea8d;p=GitHub%2FWoltLab%2FWCF.git Make CacheHandler::getCacheName() less expensive The old implementation generated cache filenames that are a little cleaner to the human eye, but the generation was needlessly expensive, even calling the UTF-8-safe StringUtil::firstCharToUpperCase() on an ASCII value. It will need to be checked if the changing cache name will cause issues during the upgrade to 5.5, as it will implicitly result in a cache clear. --- diff --git a/wcfsetup/install/files/lib/system/cache/CacheHandler.class.php b/wcfsetup/install/files/lib/system/cache/CacheHandler.class.php index 7a4fbcaec8..6775704b8f 100644 --- a/wcfsetup/install/files/lib/system/cache/CacheHandler.class.php +++ b/wcfsetup/install/files/lib/system/cache/CacheHandler.class.php @@ -6,7 +6,6 @@ use wcf\system\cache\builder\ICacheBuilder; use wcf\system\cache\source\DiskCacheSource; use wcf\system\exception\SystemException; use wcf\system\SingletonFactory; -use wcf\util\StringUtil; /** * Manages transparent cache access. @@ -118,14 +117,16 @@ class CacheHandler extends SingletonFactory */ protected function getCacheName(ICacheBuilder $cacheBuilder, array $parameters = []) { - $className = \explode('\\', \get_class($cacheBuilder)); - $application = \array_shift($className); - $cacheName = \str_replace('CacheBuilder', '', \array_pop($className)); + $cacheName = \str_replace( + ['\\', 'system_cache_builder_'], + ['_', ''], + \get_class($cacheBuilder) + ); if (!empty($parameters)) { $cacheName .= '-' . $this->getCacheIndex($parameters); } - return $application . '_' . StringUtil::firstCharToUpperCase($cacheName); + return $cacheName; } /**