本文介绍了使用Memcached进行页面缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Ruby on Rails 3应用程序中使用Memcached.它非常适合操作和片段缓存,但是当我尝试使用页面缓存时,页面存储在文件系统中,而不是存储在Memcached中.如何告诉Rails也使用Memcached进行页面缓存?

I am using Memcached in my Ruby on Rails 3 app. It works great with action and fragment caching, but when I try to use page caching, the page is stored in the filesystem instead of in Memcached. How can I tell Rails to use Memcached for page caching too?

在我的development.rb文件中:

In my development.rb file:

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

推荐答案

您不能. memcached中的页面缓存等效于操作缓存,因为该请求必须通过Rails提供.页面缓存旨在绕过Rails,因此数据必须存储在可以从服务器提供服务的文件中,例如Nginx或Apache.页面缓存之所以如此之快是因为它确实完全绕过了Rails.这是Rails文档所说的:

You cant. The equivalent of page caching in memcached is action caching, because the request must be served through Rails. Page caching is meant to bypass Rails, so the data must be stored in a file that can be served from the server, like Nginx or Apache. The reason page caching is so fast is that it does bypass Rails entirely. Here is what the Rails documentation says:

您可以在此处找到更多信息.

You can find more information here.

这篇关于使用Memcached进行页面缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 07:17
查看更多