From 144c91ae02d887e12285198cfd07faa244276531 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 17 Apr 2026 16:20:11 +0000 Subject: [PATCH] ContainerDefinitionFetcher: cache the containers.json in apcu Agent-Logs-Url: https://github.com/nextcloud/all-in-one/sessions/b8bc4ea2-eee0-4e3f-bd71-d1c5a38c93e9 perf: set apc.shm_size=32M explicitly in mastercontainer Dockerfile Agent-Logs-Url: https://github.com/nextcloud/all-in-one/sessions/4af50c77-4ac1-4947-9b35-dc66d0d0cc8b perf: revert all previous changes; cache containers.json in APCu Agent-Logs-Url: https://github.com/nextcloud/all-in-one/sessions/59281e92-7e5d-40ef-a152-78e0620eb949 perf: address review comments - clarify cache comment, restore readonly constructors Agent-Logs-Url: https://github.com/nextcloud/all-in-one/sessions/b8bc4ea2-eee0-4e3f-bd71-d1c5a38c93e9 Co-Authored-By: szaimen <42591237+szaimen@users.noreply.github.com> --- Containers/mastercontainer/Dockerfile | 3 +++ php/src/ContainerDefinitionFetcher.php | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) 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');