问题
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