diff --git a/src/main/BitrixNeverInclude.php b/src/main/BitrixNeverInclude.php index 733ca8f..7b82125 100644 --- a/src/main/BitrixNeverInclude.php +++ b/src/main/BitrixNeverInclude.php @@ -25,6 +25,7 @@ class BitrixNeverInclude */ protected static $excludedModulesIndex = null; + /** * Добавить исключение модулей из обработки * @@ -64,16 +65,23 @@ public static function registerModuleAutoload() */ public static function getClassMapping(): array { - $closure = function () { - $tools = new Tools(); - $tools->includeAllInstalledModules(); + static $mapping = null; + + //Для уменьшения запроса кеша. + if (is_null($mapping)) { + $closure = function () { + $tools = new Tools(); + $tools->includeAllInstalledModules(); - return $tools->getModuleByClassNameMapping($tools->getAutoLoadClasses()); - }; + return $tools->getModuleByClassNameMapping($tools->getAutoLoadClasses()); + }; + + $mapping = (new BitrixCache())->setTime(86400) + ->setTag(self::CACHE_TAG) + ->callback($closure); + } - return (new BitrixCache())->setTime(86400) - ->setTag(self::CACHE_TAG) - ->callback($closure); + return $mapping; } /**