diff --git a/Containers/mastercontainer/Dockerfile b/Containers/mastercontainer/Dockerfile index af14f423..ab8e81f9 100644 --- a/Containers/mastercontainer/Dockerfile +++ b/Containers/mastercontainer/Dockerfile @@ -53,6 +53,9 @@ RUN set -ex; \ build-base; \ pecl install APCu-5.1.28; \ docker-php-ext-enable apcu; \ + { \ + echo 'apc.shm_size=32M'; \ + } >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ docker-php-ext-enable opcache; \ { \ echo 'opcache.enable=1'; \ diff --git a/php/src/ContainerDefinitionFetcher.php b/php/src/ContainerDefinitionFetcher.php index 44b1a4f9..e4625a24 100644 --- a/php/src/ContainerDefinitionFetcher.php +++ b/php/src/ContainerDefinitionFetcher.php @@ -39,7 +39,14 @@ readonly class ContainerDefinitionFetcher { */ private function GetDefinition(): array { - $data = json_decode((string)file_get_contents(DataConst::GetContainersDefinitionPath()), true, 512, JSON_THROW_ON_ERROR); + $containersDefinitionPath = DataConst::GetContainersDefinitionPath(); + $cacheKey = 'containers-json-' . $containersDefinitionPath; + $cachedJson = apcu_fetch($cacheKey); + if (!is_string($cachedJson)) { + $cachedJson = (string)file_get_contents($containersDefinitionPath); + apcu_add($cacheKey, $cachedJson); + } + $data = json_decode($cachedJson, true, 512, JSON_THROW_ON_ERROR); // We store this information for later because we need to use it to distinct between community containers and default containers. $standardContainerNames = array_column($data['aio_services_v1'], 'container_name');