【问题标题】:Expire option doesn't work in Rails.cache过期选项在 Rails.cache 中不起作用
【发布时间】:2010-12-02 01:20:58
【问题描述】:

我在 Rails 2.3.10 中使用带有 :expires_in 选项的 Rails.cache.fetch 方法。

Rails.cache.fetch "key", :expires_in => 2.seconds

在开发中,我的缓存永远不会过期,Rails 总是会命中缓存。

日志:“缓存命中”

【问题讨论】:

    标签: ruby-on-rails memcached


    【解决方案1】:

    Rails 2 中的默认缓存是ActiveSupport::Cache::MemoryStore。它不支持使用 :expires_in 选项过期。事实上,只有ActiveSupport::Cache::MemCacheStore支持缓存过期。

    在 Rails 3 中,所有缓存存储都支持 :expires_in

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-25
      相关资源
      最近更新 更多