1

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 > 

为什么?

4

1 回答 1

2

如果您以这种方式定义到期,memcached 的限制为 30 天 - Memcache 最大密钥到期时间

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

于 2012-07-14T22:45:24.880 回答