本文介绍了什么是 Ruby on Rails Action Cable 适配器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

浏览 RoR 操作电缆指南 http://edgeguides.rubyonrails.org/action_cable_overview.html#subscription-adapter ,没有找到关于动作电缆适配器的太多信息.

looking through RoR action cable guide http://edgeguides.rubyonrails.org/action_cable_overview.html#subscription-adapter , didn't found much information about action cable adapter.

development:
  adapter: async

test:
  adapter: async

production:
  adapter: redis
  url: redis://10.10.3.153:6381

您能否解释一下什么是异步适配器以及为什么我需要在生产环境中将redis用作适配器?

Could you explain what is async adapter and why do I need redis in production as adapter?

推荐答案

async 适配器是 inline 适配器的异步版本,它将发布/订阅存储在内存中一个 Rails 实例,因此如果给定的实例被杀死,所有数据都将丢失.出于同样的原因,它不可扩展.

async adapter is an asynchronous version of an inline adapter, which stores pubs/subs in the memory of a Rails instance, therefore all data will be lost if given instance is killed. For the same reason it is not scalable.

Rails 推荐使用 Redis,因为它比 PostgreSQL 快得多.

Rails recommends Redis because it's way faster than PostgreSQL.

如果您真的想知道所有订阅适配器是如何工作的,您可以查看 他们的源代码.

If you really wonder how do all subscription adapters work, you can check out their source code.

这篇关于什么是 Ruby on Rails Action Cable 适配器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 06:02