启用perform_caching防止缓存未命中警告 [英] Prevent cache miss warnings with perform_caching on

查看:94
本文介绍了启用perform_caching防止缓存未命中警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Rails 3.2应用程序中尝试缓存,并通过将其添加到我的development.rb文件中来启用缓存:

config.action_controller.perform_caching = true

缓存可以按预期工作,除了在我加载任何页面时控制台会显示大量的这些日志条目:

Completed 200 OK in 1006ms (Views: 249.2ms)
cache: [GET /assets/jquery_ujs.js?body=1] miss
cache: [GET /assets/chosen.jquery.min.js?body=1] miss
cache: [GET /assets/bootstrap/bootstrap-tooltip.js?body=1] miss
cache: [GET /assets/bootstrap/tabs.js?body=1] miss
cache: [GET /assets/jquery-ui.js?body=1] miss
cache: [GET /assets/jquery.notifications-1.1.js?body=1] miss
cache: [GET /assets/jquery.js?body=1] miss
cache: [GET /assets/jquery.tablesorter.min.js?body=1] miss
cache: [GET /assets/spin.js?body=1] miss
cache: [GET /assets/olark.js?body=1] miss
cache: [GET /assets/simplemodal/basic.js?body=1] miss
cache: [GET /assets/simplemodal/jquery.simplemodal.js?body=1] miss
cache: [GET /assets/vendor_application.js?body=1] miss
cache: [GET /assets/scrollto.jquery.min.js?body=1] miss
cache: [GET /assets/bootstrap.css?body=1] miss
cache: [GET /assets/scroller.jquery.js?body=1] miss
cache: [GET /assets/application.js?body=1] miss
cache: [GET /assets/application.css?body=1] miss
cache: [GET /assets/simplemodal.css?body=1] miss
cache: [GET /assets/connections.js?body=1] miss

我应该担心那些缓存未命中吗?有什么办法可以解决这个问题/让他们沉默吗?

我正在使用资产管道,并与dalli一起进行内存缓存.

解决方案

Dalli的最新版本(在2.0.3之后)可能会解决此问题.参见: https://github.com/mperham/dalli/issues/207

迈克的承诺今天增加了沉默!方法.您需要在初始化器上设置Rails.cache.silence!才能生效.

您可以更新gemfile,以从Github获取最新的Dalli代码,或者等待下一个Dalli gem版本发布.

I'm experimenting with caching in my Rails 3.2 app and enabled caching by adding this to my development.rb file:

config.action_controller.perform_caching = true

Caching works as expected, except that when I load any page the console shows tons of these log entries:

Completed 200 OK in 1006ms (Views: 249.2ms)
cache: [GET /assets/jquery_ujs.js?body=1] miss
cache: [GET /assets/chosen.jquery.min.js?body=1] miss
cache: [GET /assets/bootstrap/bootstrap-tooltip.js?body=1] miss
cache: [GET /assets/bootstrap/tabs.js?body=1] miss
cache: [GET /assets/jquery-ui.js?body=1] miss
cache: [GET /assets/jquery.notifications-1.1.js?body=1] miss
cache: [GET /assets/jquery.js?body=1] miss
cache: [GET /assets/jquery.tablesorter.min.js?body=1] miss
cache: [GET /assets/spin.js?body=1] miss
cache: [GET /assets/olark.js?body=1] miss
cache: [GET /assets/simplemodal/basic.js?body=1] miss
cache: [GET /assets/simplemodal/jquery.simplemodal.js?body=1] miss
cache: [GET /assets/vendor_application.js?body=1] miss
cache: [GET /assets/scrollto.jquery.min.js?body=1] miss
cache: [GET /assets/bootstrap.css?body=1] miss
cache: [GET /assets/scroller.jquery.js?body=1] miss
cache: [GET /assets/application.js?body=1] miss
cache: [GET /assets/application.css?body=1] miss
cache: [GET /assets/simplemodal.css?body=1] miss
cache: [GET /assets/connections.js?body=1] miss

Should I be worried about those cache misses? Is there any way to fix that / silence them?

I'm using the asset pipeline and memcached with dalli.

解决方案

Latest version of Dalli (after 2.0.3) might resolve this issue. See: https://github.com/mperham/dalli/issues/207

Mike's commit today added silence! method. You will need to set Rails.cache.silence! on your initializer for this take effect.

You can update your gemfile to fetch the latest Dalli code from Github or wait for next version of Dalli gem to be released.

这篇关于启用perform_caching防止缓存未命中警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆