Rails3 - Caching in development mode with Rails.cache.fetch

后端 未结 1 687
借酒劲吻你
借酒劲吻你 2020-12-30 03:37

In development, the following (simplified) statement always logs a cache miss, in production it works as expected:

@categories = Rails.cache.fetch(\"categori         


        
1条回答
  •  执念已碎
    2020-12-30 04:24

    Try placing the following in /config/environments/development.rb:

    # Temporarily enable caching in development (COMMENT OUT WHEN DONE!)
    config.action_controller.perform_caching = true
    

    Additionally, if your cache store configuration is in /config/environments/production.rb, then you will need to copy the appropriate line into development.rb as well. For example, if your cache store is the Dalli memcache gem:

    # copied from production.rb into development.rb for caching in development
    config.cache_store = :dalli_store, '127.0.0.1' 
    

    Hope that helps.

    0 讨论(0)
提交回复
热议问题