Clear Memcached on Heroku Deploy

前端 未结 9 1736
旧巷少年郎
旧巷少年郎 2020-12-13 09:18

What is the best way to automatically clear Memcached when I deploy my rails app to Heroku?

I\'m caching the home page, and when I make changes and redeploy, the pag

9条回答
  •  感情败类
    2020-12-13 09:47

    25 Jan 2013: this is works for a Rails 3.2.11 app running on Ruby 1.9.3 on Cedar

    In your Gemfile add the following line to force ruby 1.9.3:

    ruby '1.9.3'
    

    Create a file named lib/tasks/clear_cache.rake with this content:

    if Rake::Task.task_defined?("assets:precompile:nondigest")
      Rake::Task["assets:precompile:nondigest"].enhance do
        Rails.cache.clear
      end
    else
      Rake::Task["assets:precompile"].enhance do
        # rails 3.1.1 will clear out Rails.application.config if the env vars
        # RAILS_GROUP and RAILS_ENV are not defined. We need to reload the
        # assets environment in this case.
        # Rake::Task["assets:environment"].invoke if Rake::Task.task_defined?("assets:environment")
        Rails.cache.clear
      end
    end
    

    Finally, I also recommend running heroku labs:enable user-env-compile on your app so that its environment is available to you as part of the precompilation.

提交回复
热议问题