What is Ruby on Rails Action Cable adapter?

本小妞迷上赌 提交于 2019-12-10 19:13:55

问题


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

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


回答1:


Action Cable provides a subscription adapter interface to process its pubsub internals. By default, asynchronous, inline, PostgreSQL, evented Redis, and non-evented Redis adapters are included. The default adapter in new Rails applications is the asynchronous (async) adapter.

In software engineering, the adapter pattern is a software design pattern that allows the interface of an existing class to be used as another interface. It is often used to make existing classes work with others without modifying their source code.

In the context of Action Cable, it basically means what DB you're gonna use to store data about your pubs/subs. Rails choses Redis because it's a way faster than PostgeSQL.

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



来源:https://stackoverflow.com/questions/39948416/what-is-ruby-on-rails-action-cable-adapter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!