什么是 Ruby on Rails Action Cable 适配器?

div*_*ero 5 ruby-on-rails websocket ruby-on-rails-5 actioncable

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

development:
  adapter: async

test:
  adapter: async

production:
  adapter: redis
  url: redis://10.10.3.153:6381
Run Code Online (Sandbox Code Playgroud)

你能解释一下什么是异步适配器,为什么我在生产中需要redis作为适配器?

Vik*_*tor 5

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

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

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

  • 这并没有回答异步适配器实际上是什么。 (2认同)