back

by nate·13y ago·view on hn ↗
Thanks for answering that. Yep, there's a bit here:

https://github.com/n8/multi_fetch_fragments/blob/master/lib/...

@collection.each do |item| key = @options[:cache].is_a?(Proc) ? @options[:cache].call(item) : item expanded_key = ActiveSupport::Cache.expand_cache_key(key) keys_to_collection_map[expanded_key] = item end

Where I use ActiveSupport::Cache.expand_cache_key to create a key based on the item or the Proc passed in. And expand_cache_key does the work of coming up with the proper key. And activerecord objects have a default cache_key implemented that uses an updated_at timestamp if it's available:

http://api.rubyonrails.org/classes/ActiveRecord/Integration....

1 comments
Another thing to note is that typical memcached configurations have a short max key length (256 or 512 or something like that).