# Handles templates caching. If a key is given and caching is on # always check the cache before hitting the resolver. Otherwise, # it always hits the resolver but if the key is present, check if the # resolver is fresher before returning it. defcached(key, path_info, details, locals) #:nodoc: name, prefix, partial = path_info locals = locals.map { |x| x.to_s }.sort!
if key @cache.cache(key, name, prefix, partial, locals) do decorate(yield, path_info, details, locals) end else decorate(yield, path_info, details, locals) end end
# Cache the templates returned by the block defcache(key, name, prefix, partial, locals) ifResolver.caching? @data[key][name][prefix][partial][locals] ||= canonical_no_templates(yield) else fresh_templates = yield cached_templates = @data[key][name][prefix][partial][locals]
if templates_have_changed?(cached_templates, fresh_templates) @data[key][name][prefix][partial][locals] = canonical_no_templates(fresh_templates) else cached_templates || NO_TEMPLATES end end end