Skip to content

Commit 0cab3e5

Browse files
authored
Merge pull request #8711 from kenjis/feat-config-check-shows-config-cache
feat: `spark config:check` detects Config Caching
2 parents c3817a6 + 6b80f3d commit 0cab3e5

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

system/Commands/Utilities/ConfigCheck.php

+14
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313

1414
namespace CodeIgniter\Commands\Utilities;
1515

16+
use CodeIgniter\Cache\FactoriesCache;
1617
use CodeIgniter\CLI\BaseCommand;
1718
use CodeIgniter\CLI\CLI;
1819
use CodeIgniter\Config\BaseConfig;
20+
use Config\Optimize;
1921
use Kint\Kint;
2022

2123
/**
@@ -87,6 +89,14 @@ public function run(array $params)
8789
/** @var class-string<BaseConfig> $class */
8890
$class = $params[0];
8991

92+
// Load Config cache if it is enabled.
93+
$configCacheEnabled = class_exists(Optimize::class)
94+
&& (new Optimize())->configCacheEnabled;
95+
if ($configCacheEnabled) {
96+
$factoriesCache = new FactoriesCache();
97+
$factoriesCache->load('config');
98+
}
99+
90100
$config = config($class);
91101

92102
if ($config === null) {
@@ -103,6 +113,10 @@ public function run(array $params)
103113
);
104114
}
105115

116+
CLI::newLine();
117+
$state = CLI::color($configCacheEnabled ? 'Enabled' : 'Disabled', 'green');
118+
CLI::write('Config Caching: ' . $state);
119+
106120
return EXIT_SUCCESS;
107121
}
108122

user_guide_src/source/general/configuration.rst

+9-2
Original file line numberDiff line numberDiff line change
@@ -378,10 +378,11 @@ Confirming Config Values
378378
************************
379379

380380
The actual Config object property values are changed at runtime by the :ref:`registrars`
381-
and :ref:`Environment Variables <configuration-classes-and-environment-variables>`.
381+
and :ref:`Environment Variables <configuration-classes-and-environment-variables>`,
382+
and :ref:`factories-config-caching`.
382383

383384
CodeIgniter has the following :doc:`command <../cli/spark_commands>` to check
384-
Config values.
385+
the actual Config values.
385386

386387
.. _spark-config-check:
387388

@@ -417,3 +418,9 @@ The output is like the following:
417418
public 'CSPEnabled' -> boolean false
418419
)
419420
421+
Config Caching: Disabled
422+
423+
You can see if Config Caching is eabled or not.
424+
425+
.. note:: If Config Caching is enabled, the cached values are used permanently.
426+
See :ref:`factories-config-caching` for details.

0 commit comments

Comments
 (0)