cache_digests
cache_digests copied to clipboard
Request: allow explicit opt-out of digest
Because Memcache has no way of searching for a key by regex and cache_digests adds an MD5 hash to the end of all cache keys (with the notable exception of any keys that are arrays with the first element being "v#"), I humbly request an additional way to indicate an explicit opt-out of the addition of the fragment digest for a single cache call. This would allow something like this:
<%= cache ['v1', 'sidebar-navigation'] do %>
<%= render "sidebar-item", :collection => expensive_queried_collection %>
<% end %>
My cached navigation only needs to be invalidated after I update one of the items in the collection but there's no way to find this using Memcache due to the MD5 hash. In this circumstance, having a key without an MD5 hash would allow easy lookup and expiration.
Implementation ideas:
<%# view %>
<%= cache 'sidebar-navigation', :skip_cache_digest => false do %>
# lib/cache_digests/fragment_helper.rb
def fragment_for(key, options = nil, &block)
skip_digest = expicitly_versioned_cache_key? || (options && options.delete(:skip_cache_digest))
# ...
end
I'll submit a PR if this idea seems acceptable.
I like skip_digest: true. Do make it so.
On Nov 20, 2012, at 22:51, Drew Ulmer [email protected] wrote:
Because Memcache has no way of searching for a key by regex and cache_digests adds an MD5 hash to the end of all cache keys (with the notable exception of any keys that are arrays with the first element being "v#"), I humbly request an additional way to indicate an explicit opt-out of the addition of the fragment digest for a single cache call. This would allow something like this:
<%= cache ['v1', 'sidebar-navigation'] do %> <%= render "sidebar-item", :collection => expensive_queried_collection %> <% end %> My cached navigation only needs to be invalidated after I update one of the items in the collection but there's no way to find this using Memcache due to the MD5 hash. In this circumstance, having a key without an MD5 hash would allow easy lookup and expiration.
Implementation ideas:
<%# view %> <%= cache 'sidebar-navigation', :skip_cache_digest => false do %>
lib/cache_digests/fragment_helper.rb
def fragment_for(key, options = nil, &block) skip_digest = expicitly_versioned_cache_key? || (options && options.delete(:skip_cache_digest))
...
end I'll submit a PR if this idea seems acceptable.
— Reply to this email directly or view it on GitHub.