【问题标题】:Fragment Caching with Memcached使用 Memcached 进行片段缓存
【发布时间】:2010-09-20 11:19:14
【问题描述】:

Rails 中是否可以使用 Memcached 进行片段缓存?

【问题讨论】:

    标签: ruby-on-rails ruby caching memcached fragment-caching


    【解决方案1】:

    你可以把它添加到你的 development.rb 中,它应该和其他的一样做片段缓存

    config.action_controller.perform_caching = true
    config.cache_classes = true
    config.cache_store = :mem_cache_store
    

    【讨论】:

      【解决方案2】:

      你可以在你的 environment.rb 中设置 fragment_cache_store

        ActionController::Base.cache_store = ActiveSupport::Cache::MemCacheStore.new()
      

      http://api.rubyonrails.org/classes/ActionController/Caching.html#M000628

      【讨论】:

      • 你应该小心在environment.rb中设置它,你的development.rb可以用perform_caching=false覆盖它,我认为最好把它放在development.rb中
      猜你喜欢
      • 1970-01-01
      • 2011-08-14
      • 2013-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多