Rails 3.2应用程序中意外的Memcache GET [英] Unexpected memcache GETs in rails 3.2 app

查看:64
本文介绍了Rails 3.2应用程序中意外的Memcache GET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Rails 3.2应用程序试图从我不希望其缓存的缓存(通过dalli进行memcached)中获取值.它没有得到任何缓存命中,但是我对正在发生的事情感到困惑.在使用WEBrick进行生产和开发时,config.action_controller.perform_caching = true都会发生这种情况.

My rails 3.2 app is trying to fetch values from the cache (memcached via dalli) that I'm not expecting it to be caching. It's not getting any cache hits, but I'm puzzled about what is going on. This happens with config.action_controller.perform_caching = true on production as well as development, using WEBrick.

以下是我在内存缓存详细输出中看到的摘要:

Here's a snippet of what I'm seeing in memcache verbose output:

<30 GET https://www.myrailsapp.com/?
>30 Writing an error: Not found
>30 Writing bin response:
>30   0x81 0x00 0x00 0x00
>30   0x00 0x00 0x00 0x01
>30   0x00 0x00 0x00 0x09
>30   0x00 0x00 0x00 0x00
>30   0x00 0x00 0x00 0x00
>30   0x00 0x00 0x00 0x00
<30 Read binary protocol data:
<30    0x80 0x00 0x00 0xd0
<30    0x00 0x00 0x00 0x00
<30    0x00 0x00 0x00 0xd0
<30    0x00 0x00 0x00 0x00
<30    0x00 0x00 0x00 0x00
<30    0x00 0x00 0x00 0x00

请注意,只有一个缓存GET,我看不到任何缓存写入.

Note that there is only a cache GET and I'm not seeing any cache writes.

我对我的所有操作都看到了类似的缓存GET尝试,其中大多数是JSON API调用.所有这些都会导致高速缓存未命中.像这样

I see similar cache GET attempts for all my actions, most of which are JSON API calls. All of them result in a cache miss. Like this,

<31 GET https://www.myrailsapp.com/api/somecall?param1=foo&param2=bar
>31 Writing an error: Not found

我在应用程序的任何地方都没有指定任何caches_action指令.

I have not specified any caches_action directives anywhere in my app.

这是Rails的错误吗?

Is this a rails bug?

如果否,我应该在哪里停止这些不必要的缓存GET?

If no, where should I look to stop these unnecessary cache GETs?

谢谢.

推荐答案

根据您发布的Github线程上的cswilliams:

As per cswilliams on the Github thread you've posted:

默认情况下启用rack_cache似乎是一个问题(因为在master分支中已更新).

It appears to be an issue with the rack_cache being enabled by default (since updated in the master branch).

在您的应用程序或环境属性文件(例如config/environments/development.rb)中将其禁用似乎可以解决该问题:

Disabling it in your application or environments properties file (e.g., config/environments/development.rb) seems to resolve the issue:

config.action_dispatch.rack_cache = false

这篇关于Rails 3.2应用程序中意外的Memcache GET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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