Clearing Memcached at Capistrano Deployment
It’s a two step process:
- Create a rake task (in lib/tasks/clear_memcached.rake for example):
namespace :cache do
desc 'Clear memcache'
task :clear => :environment do
ActionController::Base.cache_store.clear
end
end
- In deploy.rb add the following:
namespace :cache do
desc "Clear memcach after deployment"
task :clear, :roles => :app do
run "cd #{current_release} && rake cache:clear RAILS_ENV=production"
end
end
and (depending on your task chain):
after "deploy:update_code", "cache:clear"
Hope it helps.
Posted: 12 July 2010