mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Moving core cache configuration out of Configure and into core.php.
This makes the cache configurations cake uses internally more transparent, and easier for the end developer to configure. Fixes #1586
This commit is contained in:
parent
d0dfd7f18c
commit
70d334f7eb
2 changed files with 40 additions and 38 deletions
|
@ -283,4 +283,43 @@
|
|||
* ));
|
||||
*
|
||||
*/
|
||||
Cache::config('default', array('engine' => 'File'));
|
||||
|
||||
// Pick the caching engine to use. If APC is enabled use it.
|
||||
$engine = 'File';
|
||||
if (extension_loaded('apc')) {
|
||||
$engine = 'Apc';
|
||||
}
|
||||
|
||||
// Setup a 'default' cache configuration for use in the application.
|
||||
Cache::config('default', array('engine' => $engine));
|
||||
|
||||
// In development mode, caches should expire quickly.
|
||||
$duration = '+999 days';
|
||||
if (Configure::read('debug') >= 1) {
|
||||
$duration = '+10 seconds';
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the cache used for general framework caching. Path information,
|
||||
* object listings, and translation cache files are stored with this configuration.
|
||||
*/
|
||||
Cache::config('_cake_core_', array(
|
||||
'engine' => $engine,
|
||||
'prefix' => 'cake_core_',
|
||||
'path' => CACHE . 'persistent' . DS,
|
||||
'serialize' => ($engine === 'File'),
|
||||
'duration' => $duration
|
||||
));
|
||||
|
||||
/**
|
||||
* Configure the cache for model, and datasource caches. This cache configuration
|
||||
* is used to store schema descriptions, and table listings in connections.
|
||||
*/
|
||||
Cache::config('_cake_model_', array(
|
||||
'engine' => $engine,
|
||||
'prefix' => 'cake_model_',
|
||||
'path' => CACHE . 'models' . DS,
|
||||
'serialize' => ($engine === 'File'),
|
||||
'duration' => $duration
|
||||
));
|
||||
|
||||
|
|
|
@ -73,43 +73,6 @@ class Configure {
|
|||
trigger_error(__("Can't find application core file. Please create %score.php, and make sure it is readable by PHP.", CONFIGS), E_USER_ERROR);
|
||||
}
|
||||
|
||||
if (empty(self::$_values['Cache']['disable'])) {
|
||||
$cache = Cache::config('default');
|
||||
|
||||
if (empty($cache['settings'])) {
|
||||
trigger_error(__('Cache not configured properly. Please check Cache::config(); in APP/config/core.php'), E_USER_WARNING);
|
||||
$cache = Cache::config('default', array('engine' => 'File'));
|
||||
}
|
||||
$path = $prefix = $duration = null;
|
||||
|
||||
if (!empty($cache['settings']['path'])) {
|
||||
$path = realpath($cache['settings']['path']);
|
||||
} else {
|
||||
$prefix = $cache['settings']['prefix'];
|
||||
}
|
||||
|
||||
if (self::$_values['debug'] >= 1) {
|
||||
$duration = '+10 seconds';
|
||||
} else {
|
||||
$duration = '+999 days';
|
||||
}
|
||||
$cacheConfigs = Cache::configured();
|
||||
|
||||
if (!in_array('_cake_core_', $cacheConfigs)) {
|
||||
Cache::config('_cake_core_', array_merge((array)$cache['settings'], array(
|
||||
'prefix' => $prefix . 'cake_core_', 'path' => $path . DS . 'persistent' . DS,
|
||||
'serialize' => true, 'duration' => $duration
|
||||
)));
|
||||
}
|
||||
|
||||
if (!in_array('_cake_model_', $cacheConfigs)) {
|
||||
Cache::config('_cake_model_', array_merge((array)$cache['settings'], array(
|
||||
'prefix' => $prefix . 'cake_model_', 'path' => $path . DS . 'models' . DS,
|
||||
'serialize' => true, 'duration' => $duration
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
App::init();
|
||||
App::build();
|
||||
if (!include(CONFIGS . 'bootstrap.php')) {
|
||||
|
|
Loading…
Reference in a new issue