【问题标题】:dalli on heroku not cachingheroku上的dalli没有缓存
【发布时间】:2013-05-17 10:26:39
【问题描述】:

我想在 Heroku 上的 Rails 应用中启用动作缓存。 在development.rb我设置:

  config.action_controller.perform_caching = true

在日志中查看

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

-> 为了转移到生产环境,我通过 $heroku addons:add memcache 安装了 memcache 插件,在 Gemfile 中安装了新的 gem:gem 'dalli',并在 production.rb 中更改了设置:

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

我也尝试启用这两个注释参数,但无论如何我没有在日志中看到 Read/Write fragment ... 片段,我看到应用程序已通过身份验证,但缓存总是丢失

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

运行$heroku run console我检查缓存是否正在加载:

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"

为什么动作缓存不起作用?

【问题讨论】:

    标签: heroku memcached dalli


    【解决方案1】:

    您可以尝试改用 memcachier 吗?

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

    在 DevCenter 中查看此处:Memcachier

    【讨论】:

    • 我改变了 Memcachier 但没有任何改变,但似乎缓存以某种方式工作。无论如何,谢谢)
    猜你喜欢
    • 2013-09-23
    • 2011-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-13
    • 1970-01-01
    • 1970-01-01
    • 2014-03-25
    相关资源
    最近更新 更多