Clear Memcached on Heroku Deploy

前端 未结 9 1735
旧巷少年郎
旧巷少年郎 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:44

    I deploy my applications using a bash script that automates GitHub & Heroku push, database migration, application maintenance mode activation and cache clearing action.

    In this script, the command to clear the cache is :

    heroku run --app YOUR_APP_NAME rails runner -e production Rails.cache.clear
    

    This works with Celadon Cedar with the Heroku Toolbelt package. I know this is not a Rake-based solution however it's quite efficient.

    Note : be sure you set the environment / -e option of the runner command to production as it will be executed on the development one otherwise.

    Edit : I have experienced issues with this command on Heroku since a few days (Rails 3.2.21). I did not have time to check the origin the issue but removing the -e production did the trick, so if the command does not succeed, please run this one instead :

    heroku run --app YOUR_APP_NAME rails runner Rails.cache.clear
    

提交回复
热议问题