如果Redis关闭,请禁用Rails缓存 [英] Disable Rails caching if Redis is down

查看:123
本文介绍了如果Redis关闭,请禁用Rails缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Rails 4.1并设置共享的Redis ElasticCache节点进行缓存。我尝试了 https://github.com/redis-store/redis-store 和< a href = https://github.com/sorentwo/readthis rel = nofollow> https://github.com/sorentwo/readthis ,它们看起来很棒。

I am using Rails 4.1 and and setup shared Redis ElasticCache node for caching. I tried https://github.com/redis-store/redis-store and https://github.com/sorentwo/readthis and they seem great.

但是,如果Redis掉线了怎么办? readthis和redis-store都完全失败。我宁愿网站没有缓存也要慢而不要死。

But what happens if Redis is down? Both readthis and redis-store completely fail. I'd rather have site be slow w/o cache than dead.

有人有想法吗?我提前谢谢你。

Does anyone have ideas? I thank you in advance.

推荐答案

截至 https://github.com/sorentwo/readthis/pull/30 可直接在Readthis中获得。它将在即将发布的1.2版本中提供。在自述文件中:

As of https://github.com/sorentwo/readthis/pull/30 this is available directly in Readthis. It will be available in the upcoming 1.2 release. From the README:


在某些情况下,如果Redis崩溃,最好保留服务于磁盘
或数据库的请求。通过在顶层启用连接
的容错能力,可以实现这一点:

In some situations it is desirable to keep serving requests from disk or the database if Redis crashes. This can be achieved wiht connection fault tolerance by enabling it at the top level:

Readthis.fault_tolerant = true

Readthis.fault_tolerant = true

默认值为false,因为虽然它可能适用于获取
操作,但它与
增量之类的其他基于状态的命令不兼容。

The default value is false, because while it may work for fetch operations, it isn't compatible with other state-based commands like increment.

这篇关于如果Redis关闭,请禁用Rails缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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