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

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

问题描述

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

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

但是当我抓取这个脚本时,它只显示 heroku 控制台命令行,但没有输入 Rails.cache.clear 命令.(我猜这是因为 heroku 控制台是交互式的)

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)

system "heroku console Rails.cache.clear"

不适用于 cedar 应用程序.

doesn't work for cedar apps.

我该如何解决这个问题?

How can I solve this problem?

谢谢.

推荐答案

Rails 有一个内置的 rake 任务:

Rails has a built in rake task:

rake tmp:clear

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

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