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>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-17 16:20:11 +00:00
committed by Simon L.
parent 2b5998e57d
commit 144c91ae02
2 changed files with 11 additions and 1 deletions

View File

@@ -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'; \

View File

@@ -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');