gpt4 book ai didi

ruby-on-rails - 部署到heroku后如何清除rails缓存?

转载 作者:行者123 更新时间:2023-12-03 07:52:23 25 4
gpt4 key购买 nike

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

所以我用谷歌搜索,我找到了这个。

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 控制台是交互式的)


system "heroku console Rails.cache.clear"

不适用于雪松应用程序。

我怎么解决这个问题?

谢谢。

最佳答案

Rails 有一个内置的 rake 任务:

rake tmp:clear

关于ruby-on-rails - 部署到heroku后如何清除rails缓存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12028088/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com