Rack :: Cache with redis无法正常工作

时间:2012-10-10 18:07:41

标签: ruby-on-rails-3 caching redis rack

我正在尝试设置Rack :: Cache以与dragonfly一起使用。我希望在单独的服务器上拥有共享的redis缓存,以便可以跨Web服务器共享缓存。问题是无论我传入的配置如何,它都假定url是localhost而不是我提供的IP地址。这是我的代码:

require 'uri'
require 'dragonfly'
require 'rack/cache'
require 'redis-store'
require 'redis-rack-cache'

### The dragonfly app ###
app = Dragonfly[:images]
app.configure_with(:rails)
app.configure_with(:imagemagick)

### Extend active record ###
app.define_macro(ActiveRecord::Base, :image_accessor)
app.define_macro(ActiveRecord::Base, :file_accessor)

### Insert the middleware ###
rack_cache_already_inserted = Rails.application.config.action_controller.perform_caching && Rails.application.config.action_dispatch.rack_cache

Rails.application.middleware.insert 0, Rack::Cache, {
  :verbose     => Rails.env.development?,
  :metastore   => "redis://SOMEIP:SOME_PORT/0/metastore", # URI encoded in case of spaces
  :entitystore => "redis://SOMEIP:SOME_PORT/0/entitystore",
} unless rack_cache_already_inserted

Rails.application.middleware.insert_after Rack::Cache, Dragonfly::Middleware, :images

无论我放置什么而不是SOMEIP:SOME_PORT该值被忽略并且它连接到localhost上的redis。

有什么想法吗?

(使用Rails 3.0.10)

0 个答案:

没有答案
相关问题