部署到heroku后如何清除rails cache? [英] How can I clear rails cache after deploy to heroku?

查看:253
本文介绍了部署到heroku后如何清除rails cache?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将缓存应用到我的heroku rails应用程序,并且运行良好。
但是每次我部署到heroku,我也想自动清除缓存。



所以我googled,我发现这个。

 任务:after_deploy,:env,:branch do | t,args | 
放置部署完成
放置清除所有缓存....
FileUtils.cd Rails.root do
sh%{heroku运行控制台}
sh %{Rails.cache.clear}
end
end

但是当我嘲笑这个脚本,它只显示英雄控制台命令行,但Rails.cache.clear命令不键入。 (我猜这是因为英雄控制台是互动的)



 系统英雄控制台Rails.cache.clear

不适用于雪松应用程序。 p>

如何解决这个问题?



谢谢。

解决方案

Rails有一个内置的耙子任务:

  rake tmp:clear 


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.

task :after_deploy, :env, :branch do |t, args|
  puts "Deployment Complete"
  puts "Cleaning all cache...."
  FileUtils.cd Rails.root do
    sh %{heroku run console}
    sh %{Rails.cache.clear}
  end
end

but when I raked this script, it just show the heroku console command line but the Rails.cache.clear command does not typed. (I guess that is because heroku console is interactive)

and

system "heroku console Rails.cache.clear"

doesn't work for cedar apps.

How can I solve this problem?

Thanks.

解决方案

Rails has a built in rake task:

rake tmp:clear

这篇关于部署到heroku后如何清除rails cache?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆