【问题标题】:Rails 3 cache not working. DalliRails 3 缓存不起作用。达利
【发布时间】:2012-06-29 18:03:28
【问题描述】:

development.rb 缓存配置

  config.action_controller.perform_caching = true
  config.cache_store = :dalli_store, 'localhost:11211',
    { :namespace => APP_NAME, :expires_in => 3.month, :compress => true }

production.rb 缓存配置

   config.action_controller.perform_caching = true
   config.cache_store = :dalli_store, 'localhost:11211',
     { :namespace => APP_NAME, :expires_in => 3.month, :compress => true }

在控制台中

rails c production
Loading production environment (Rails 3.2.3)
1.9.3-p125 :001 > Rails.cache.write 'res', "Hello World"
 => true 
1.9.3-p125 :002 >  Rails.cache.read 'res'
 => nil 
1.9.3-p125 :003 > 

为什么?

【问题讨论】:

  • 运行 memcached -vv 并在此处复制粘贴输出
  • 如果我将 3.month 替换为 0-30.day 90.day 也不起作用

标签: ruby ruby-on-rails-3 memcached dalli


【解决方案1】:

如果您以这种方式定义过期时间,memcached 的限制为 30 天 - Memcache maximum key expiration time

另见https://github.com/mperham/dalli/issues/55

【讨论】:

    猜你喜欢
    • 2016-09-18
    • 1970-01-01
    • 1970-01-01
    • 2016-11-18
    • 1970-01-01
    • 2016-08-13
    • 2018-03-27
    相关资源
    最近更新 更多