-
Notifications
You must be signed in to change notification settings - Fork 22
Capcake and PHP APC
franzem edited this page Oct 25, 2011
·
3 revisions
You need to empty the APC cache after a Capistrano/Capcake deploy, but you cannot do it from the command line since apc_cli and apc have different caches. You could restart your webserver (or nginx/pgp-fpm if you using that) but that means, for me, unnecessary downtime (even if it's only seconds).
This is how I solved it:
- added a function to one of my controllers to clear cache
- call that function after deploy
example function:
function clearCache() {
if (in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1'))) {
apc_clear_cache();
apc_clear_cache('user');
apc_clear_cache('opcode');
echo json_encode(array('APC Clear Cache' => true));
}
exit;
}
and added to my deploy.rb file:
namespace(:customs) do
task :apc_cache_clea, :roles => :app do
run <<-CMD
curl --insecure -s https://localhost/housekeepings/clearCache
CMD
end
end
after "deploy:symlink", "customs:apc_cache_clear"
Thanks to jeremy@stackoverflow for a good direction.