diff --git a/app/config/core.php b/app/config/core.php index 9744da06c..18c3e3926 100644 --- a/app/config/core.php +++ b/app/config/core.php @@ -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 +)); + diff --git a/cake/libs/configure.php b/cake/libs/configure.php index 5c4cc74b8..29633732c 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -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')) {