Improve live DB clone speed

This commit is contained in:
Jeppe Bundgaard
2026-03-12 13:26:22 +01:00
parent e91dda0799
commit 5cb197898d
12 changed files with 3510 additions and 34 deletions
+24 -6
View File
@@ -27,14 +27,32 @@ if (isset($_ENV['USE_ENV']) && $_ENV['USE_ENV'] === 'true') {
'REDIS_CONFIG_DATABASE' => 'database',
'REDIS_CONFIG_PASSWORD' => 'password'
];
$dbTarget = strtolower(trim((string)($_ENV['CONFIG_DB_TARGET'] ?? 'live')));
if ($dbTarget !== 'live' && $dbTarget !== 'debug') {
$dbTarget = 'live';
}
$resolveDbValue = function (string $key) use ($dbTarget): string {
$liveKey = 'CONFIG_DB_' . $key;
$debugKey = 'CONFIG_DB_DEBUG_' . $key;
$liveValue = (string)($_ENV[$liveKey] ?? '');
$debugValue = (string)($_ENV[$debugKey] ?? '');
if ($dbTarget === 'debug' && $debugValue !== '') {
return $debugValue;
}
return $liveValue;
};
/**
* Set the db configuration
* Set the db configuration from selected target (live/debug)
*/
$CONFIG_DB = [
'host' => $_ENV['CONFIG_DB_HOST'],
'user' => $_ENV['CONFIG_DB_USER'],
'password' => $_ENV['CONFIG_DB_PASSWORD'],
'database' => $_ENV['CONFIG_DB_DATABASE']
'host' => $resolveDbValue('HOST'),
'user' => $resolveDbValue('USER'),
'password' => $resolveDbValue('PASSWORD'),
'database' => $resolveDbValue('DATABASE')
];
/**
* Set the debug configuration
@@ -98,4 +116,4 @@ if (isset($_ENV['USE_ENV']) && $_ENV['USE_ENV'] === 'true') {
} else {
// Throw an error if the environment variables are not set
throw new Exception('Environment variables are not set');
}
}