mirror of
https://github.com/nextcloud/all-in-one.git
synced 2026-05-21 02:40:09 +00:00
ContainerDefinitionFetcher: cache the containers.json in apcu (#7951)
This commit is contained in:
@@ -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'; \
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user