Web Development

As we know the default Cache Engine is using file storage.

To use the APC Cache Engine, you will need to setup APC on your server and then configure your bootstrap file. I personally don’t have the APC extension loaded on my local machine and since I don’t have it setting the APC Cache Engine to default will cause errors.

A simple way to automatically set the Cache Engine to APC if you have it installed on production or wherever you have a CakePHP application with APC installed.

if (extension_loaded('apc') && function_exists('apc_dec') && (php_sapi_name() !== 'cli' || ini_get('apc.enable_cli'))) {
    Cache::config('default', array(
        'engine' => 'Apc', //[required]
        'duration'=> 3600, //[optional]
        'probability'=> 100, //[optional]
        'prefix' => Inflector::slug(APP_DIR) . '_', //[optional]  prefix every cache file with this string
} else {
    Cache::config('default', array('engine' => 'File'));

Quite easy!