1

I want to enable action caching in my rails app on heroku. In development.rb I set:

  config.action_controller.perform_caching = true

and see in logs

Started GET "..." for 127.0.0.1 at 2013-05-17 14:03:25 +0400
...
Write fragment ... 
OR
Read fragment ... (0.2ms)

-> To move to production I installed memcache add-on via $heroku addons:add memcache , installed new gem in Gemfile: gem 'dalli' and changed settings in production.rb:

config.action_controller.perform_caching = true
config.cache_store = :dalli_store #, ENV['MEMCACHE_SERVERS'], { :namespace => 'myapp', :expires_in => 1.day, :compress => true }

I have also tried to enable those two commented parameters, but anyway I don't see Read/Write fragment ... pieces in logs, I see that app gets authenticated, but cache is always missing

Started GET "..." for 195.178.108.38 at 2013-05-17 09:54:19 +0000
Dalli/SASL authenticating as myapp%40heroku.com
Dalli/SASL: Authenticated
cache: [GET ...] miss

Running $heroku run console I check that the cache is loading:

irb(main):001:0> Rails.cache.read('color')
Dalli/SASL authenticating as myapp%40heroku.com
Dalli/SASL: Authenticated
=> nil
irb(main):002:0> Rails.cache.write('color', 'red')
=> true
irb(main):003:0> Rails.cache.read('color')
=> "red"

Why action caching does not work?

4

1 回答 1

2

您可以尝试改用 memcachier 吗?

  • 删除 memcahe 附加组件
  • 添加 memcachier 插件
  • 在 gem 文件中的 "dalli" 上方添加 "memcachier" gem
  • 它应该“正常工作”

请参阅 DevCenter 中的此处:Memcachier

于 2013-05-20T15:36:04.317 回答