【问题标题】:Why rails use redis?为什么rails使用redis?
【发布时间】:2021-09-01 09:03:36
【问题描述】:

我正在尝试开发一个小型 Rails 应用程序。我之前使用 CarriereWave 来存储文件,但只是更改为使用 ActiveStorage。当我保存新记录(或销毁记录)时,应用程序崩溃并显示错误消息:

Disk Storage (1.4ms) Uploaded file to key: yltgtiwm190dz7kemaj8plz6acpq (checksum: Xjy3wdZBK+KWDKkEgTPVmw==)
[ActiveJob] Failed enqueuing ActiveStorage::AnalyzeJob to Sidekiq(default): Redis::CannotConnectError (Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED))
Completed 500 Internal Server Error in 373ms (ActiveRecord: 310.0ms | Allocations: 18043)

Redis::CannotConnectError (Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED)):

但是,记录是完美记录的。

当我启动 Redis 服务器时,一切正常,但我的问题是:

为什么我的 Rails 应用程序使用 Redis,是否可以禁用它? (由于我使用谷歌应用引擎进行生产,我不想在上面设置 Redis 服务器)。

【问题讨论】:

  • @SergioTulentsev Doop!对。哦 ActiveStorage...

标签: ruby-on-rails redis rails-activestorage


【解决方案1】:

config/environments/* 中搜索一些相关代码(缓存或其他)

这是我的 config/environments/production.rb 中将 Redis 作为缓存的示例

Rails.application.configure do
  config.cache_store = :redis_cache_store, { url: "redis://<my_server>:6379/0" }
end

搜索到 config/initializers/redis.rb

Redis 不是强制性的。你有一些代码来激活它。

建议:

$ cd my_app
$ grep -i redis * -r

【讨论】:

  • 这种情况下sidekiq需要redis,不是cache store
  • 好的,谢谢。有没有办法通过sidekiq禁用redis(或在使用ActiveStorage时禁用sidekiq)?
猜你喜欢
  • 1970-01-01
  • 2022-08-06
  • 1970-01-01
  • 2015-07-14
  • 2016-10-23
  • 1970-01-01
  • 2017-07-06
  • 2015-09-19
  • 1970-01-01
相关资源
最近更新 更多