Action Cable 5 需要 Redis 吗? [英] Does Action Cable 5 require Redis?

查看:81
本文介绍了Action Cable 5 需要 Redis 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用:

rails (5.0.2)
actioncable (5.0.2)
puma (3.8.2)

我有一个 Rails 5 Action Cable 演示聊天,一年前没有 Redis 就无法使用 - 现在可以了!(在包更新之后).

I have a Rails 5 Action Cable demo chat and a year ago it didn't work without Redis - and now it does! (after bundle update).

换句话说,我成功地让我的演示聊天在没有 Redis 的开发模式下工作.我这样设置 config/cable.yml:

In other words, I succedeed to make my demo chat to work in development mode without Redis. I set the config/cable.yml like this:

development:
  adapter: async

test:
  adapter: async

production:
  adapter: async 

并启动rails c.就是这样 - 聊天正常,没问题.所以 Redis 显然不再需要了——不像一年前那样?

and start rails c. That's it - the chat is working, no problem. So Redis is obviously not needed anymore - unlike a year-ago times?

我还找到了一种方法,让我的演示聊天能够使用 Redis.为此,我像这样更改 config/cable.yml:

Also I found a way to make my demo chat to work with Redis. To do so I change the config/cable.yml like this:

redis: &redis
  adapter: redis
  url: redis://localhost:6379/1

production: *redis
development: *redis
test: *redis

然后将 gem 'redis', '~>3.2' 添加到我的 Gemfile (+ bundle install),启动 Redis redis-server 然后 rails c.

than add gem 'redis', '~>3.2' to my Gemfile (+ bundle install), start Redis redis-server and then rails c.

所以我的问题是:

  1. Action Cable 5 是否需要 Redis 才能工作?(看起来没有,但我不确定).
  2. 如果(显然)Action Cable 5 可以使用或不使用 Redis - 有什么区别?
  3. 什么是gem 'redis', '~>3.2'?它有什么用?
  1. Does Action Cable 5 require Redis to work? (looks like don't but I'm not sure).
  2. If (apparently) Action Cable 5 can work with or without Redis - what's the difference?
  3. What is gem 'redis', '~>3.2'? What is it for?

总的来说,我不知道现在 Action Cable 5 在 Redis 使用(未使用?)方面的正确用法是什么.开发模式和生产模式有什么区别吗?

Generally I have no idea what is now the proper usage of Action Cable 5 in terms of Redis usage (non-usage?). Is there any difference for the development or production mode?

推荐答案

Action Cable 5 需要 Redis 吗?

Does Action Cable 5 require Redis?

没有.根据文档,它可以使用其他适配器.

No. According to the documentation, it's able to use other adapters.

Action Cable 提供了一个 订阅适配器接口来处理它的pubsub 内部结构. 默认情况下,异步、内联、PostgreSQL、包括事件 Redis 和非事件 Redis 适配器.这新 Rails 应用程序中的默认适配器是异步 (async)适配器.

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.

问题:

Action Cable 5 是否需要 Redis 才能工作?(看起来不像,但我是不确定).

Does Action Cable 5 require Redis to work? (looks like don't but I'm not sure).

没有

如果(显然)Action Cable 5 可以在有或没有 Redis 的情况下工作 - 有什么区别?

If (apparently) Action Cable 5 can work with or without Redis - what's the difference?

如果 ActionCable 没有区别,它使用抽象适配器并且不依赖于传输协议.

In case of ActionCable there in no differences, it uses an abstraction adapter and does not depend on transport protocol.

什么是gem 'redis', '~>3.2'?有什么用?

用于redis,提供与redis-server通信的接口.

It's for redis and provides an interface for communication with redis-server.

这篇关于Action Cable 5 需要 Redis 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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