Module: ActionController
- Defined in:
- lib/extended_fragment_cache.rb,
lib/extended_fragment_cache.rb
Overview
In-Process Memory Cache for Fragment Caching
Fragment caching has a slight inefficiency that requires two lookups within the fragment cache store to render a single cached fragment.
The two cache lookups are:
-
The read_fragment method invoked in a controller to determine if a fragment has already been cached. e.g.,
unless read_fragment("/x/y/z") ... end
-
The cache helper method invoked in a view that renders the fragment. e.g.,
<% cache("/x/y/z") do %> ... <% end %>
This plugin adds an in-process cache that saves the value retrieved from the fragment cache store. The in-process cache has two benefits:
-
It cuts in half the number of read requests sent to the fragment cache store. This can result in a considerable saving for sites that make heavy use of memcached.
-
Retrieving the fragment from the in-process cache is faster than going to fragment cache store. On a typical dev box, the savings are relatively small but would be noticeable in standard production environment using memcached (where the fragment cache could be remote)
Peter Zaitsev has a great post comparing the latencies of different cache types on the MySQL Performance blog: www.mysqlperformanceblog.com/2006/08/09/cache-performance-comparison/
The plugin automatically installs a before_filter on the ApplicationController that flushes the in-process memory cache at the start of every request.
Defined Under Namespace
Modules: Caching