Last Updated: February 25, 2016
·
608
· ashcode

Switching from File to APC for Caching

If you're starting a new project in CakePHP and you're trying to figure out how to alter the default configuration to utilize APC rather than File-based caching, please note that you have to make BOTH of the following changes in order to see the correct results:

(1) Replace this line in /app/config/core.php

Cache::config('cakecore', array(
'engine' => $engine,
'prefix' => $prefix . 'cake
core_',
'path' => CACHE . 'persistent' . DS,
'serialize' => ($engine === 'File'),
'duration' => $duration
));

with this:

Cache::config('default', array('engine' => 'Apc'));

(2) Comment out, or delete, this line in /app/config/bootstrap.php

Cache::config('default', array('engine' => 'File'));

People often forget to perform step 2 (I did) and that can lead to unnecessary confusion. Good luck!