清除Heroku部署中的Memcached [英] Clear Memcached on Heroku Deploy

查看:109
本文介绍了清除Heroku部署中的Memcached的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将Rails应用程序部署到Heroku时,自动清除Memcached的最佳方式是什么?



我正在缓存主页,当我进行更改时重新部署,页面是从缓存中提供的,并且未包含更新。



我希望这是完全自动化的。我不想在每次部署时都要清除heroku控制台中的缓存。



感谢!

解决方案

我使用bash脚本部署我的应用程序,该脚本自动化了GitHub& Heroku推送,数据库迁移,应用程序维护模式激活和缓存清除操作。

在此脚本中,清除缓存的命令为:

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

这适用于带有Heroku Toolbelt软件包的Celadon Cedar。我知道这不是一个基于Rake的解决方案,但它非常高效。



注意:确保设置环境 / -e 选项 runner 命令到生产因为它会在开发中执行一个。



编辑:我有自从几天以来,Heroku上的这个命令遇到了一些问题(Rails 3.2.21)。我没有时间检查问题的来源,但删除了 -e production 这个技巧,所以如果命令没有成功,请运行这个命令:

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


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 page is served from the cache, and the updates aren't incorporated.

I want to have this be totally automated. I don't want to have to clear the cache in the heroku console each time I deploy.

Thanks!

解决方案

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

这篇关于清除Heroku部署中的Memcached的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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