update config and remove check for container in cache.php

This commit is contained in:
alexveebee 2025-04-23 15:13:07 +00:00
parent 0a0cf68d64
commit 240bb247f9
2 changed files with 20 additions and 25 deletions

View File

@ -25,19 +25,10 @@ class Cache {
$password = $config['cache']['redis'][2] ?? ''; $password = $config['cache']['redis'][2] ?? '';
$database = $config['cache']['redis'][3] ?? 1; $database = $config['cache']['redis'][3] ?? 1;
if ($config['is_docker']) { $host = getenv('VICHAN_CACHE_HOST') ?: $host;
$host = getenv('VICHAN_REDIS_HOST') ?: $host; $port = getenv('VICHAN_CACHE_PORT') ?: $port;
$port = getenv('VICHAN_REDIS_PORT') ?: $port; $password = getenv('VICHAN_CACHE_PASSWORD') ?: $password;
$password = getenv('VICHAN_REDIS_PASSWORD') ?: $password; $database = getenv('VICHAN_CACHE_DATABASE') ?: $database;
$database = getenv('VICHAN_REDIS_DATABASE') ?: $database;
}
// $log->log("Cache info:\n"
// . 'Cache driver: redis' . "\n"
// . '├ Redis host: ' . $host . "\n"
// . '├ Redis port: ' . $port . "\n"
// . '├ Redis password: ' . str_repeat('*', strlen($password)) . "\n"
// . '└ Redis database: ' . $database . "\n"
// );
return new RedisCacheDriver( return new RedisCacheDriver(
$config['cache']['prefix'], $config['cache']['prefix'],

View File

@ -137,15 +137,16 @@
* ==================== * ====================
*/ */
// Determine if Redis is configured via environment variables
$redis_enabled = getenv('VICHAN_REDIS_HOST') !== false && getenv('VICHAN_REDIS_PORT') !== false;
// Configure cache
if ($redis_enabled) {
$config['cache']['enabled'] = 'redis';
} else {
$config['cache']['enabled'] = 'php'; $config['cache']['enabled'] = 'php';
} $config['cache']['redis'] = array(
'host' => 'localhost',
'port' => 6379,
'password' => '',
'database' => 1
);
// Determine if Redis is configured via environment variables
getenv('VICHAN_CACHE_ENGINE') && $config['cache']['enabled'] = getenv('VICHAN_CACHE_ENGINE');
// Cache timeout for cached objects // Cache timeout for cached objects
$config['cache']['timeout'] = 60 * 60 * 48; // 48 hours $config['cache']['timeout'] = 60 * 60 * 48; // 48 hours
@ -1854,12 +1855,15 @@
/* /*
* ==================== * ====================
* Docker settings * Container settings
* =================== * ===================
*/ */
$isDocker = is_file("/.dockerenv") || is_file("/run/.containerenv"); $isDocker = is_file("/.dockerenv") || is_file("/run/.containerenv");
$isKubernetes = is_file("/var/run/secrets/kubernetes.io/serviceaccount/namespace");
$config['is_container'] = $isDocker || $isKubernetes ? true : false;
$config['is_docker'] = $isDocker; $config['is_docker'] = $isDocker;
$config['is_kubernetes'] = $isKubernetes;
/* /*
* ==================== * ====================