Dirk Bergmann

Developer, panographer. Does consultancy work from own company. Lives in Chiang Mai, Thailand.

Twitter

Chiang Mai

Hua Hin

Thailand Hotels

ListVote - List. Vote. Learn.

Partnerseek - Find Partners

Clearing Memcached at Capistrano Deployment

It?s a two step process:

  1. Create a rake task (in lib/tasks/clear_memcached.rake for example):
{:tag :br, :attrs nil, :content []}namespace :cache do
desc 'Clear memcache'
 task :clear => :environment do
ActionController::Base.cache_store.clear
end
end
  1. 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):

{:tag :br, :attrs nil, :content []}after "deploy:update_code", "cache:clear"

Hope it helps.