How can I clear rails cache after deploy to heroku?

前端 未结 7 2031
暖寄归人
暖寄归人 2020-12-13 13:21

I applied cache to my heroku rails app and it works well. But everytime I deploy to heroku, I also want to clear cache automatically.

so I googled and I found this

7条回答
  •  无人及你
    2020-12-13 13:58

    You should be able to create a cache clearing rake task that looks something like this:

    namespace :cache do
      desc "Clears Rails cache"
      task :clear => :environment do
        Rails.cache.clear
      end
    end
    

    and invoke it directly in one command that you can use in your post deploy hook - like so:

    heroku run rake cache:clear
    

提交回复
热议问题