Clearing Memcached at Capistrano Deployment

Capistrano, Ruby on Rails Add comments

It’s a two step process:

1. 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

2. 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.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in