From d6bac046922fcee05366d26d75349dde70d25f6b Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 17 May 2016 11:28:40 -0700 Subject: keep layouts + locals from bloating the cache Using locals will cause layouts to be cached multiple times in the template cache. This commit removes locals from consideration when looking up the layout. --- actionview/lib/action_view/template/resolver.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'actionview/lib/action_view/template') diff --git a/actionview/lib/action_view/template/resolver.rb b/actionview/lib/action_view/template/resolver.rb index c5e69b1833..bf68e93c58 100644 --- a/actionview/lib/action_view/template/resolver.rb +++ b/actionview/lib/action_view/template/resolver.rb @@ -88,6 +88,23 @@ module ActionView @query_cache.clear end + # Get the cache size. Do not call this + # method. This method is not guaranteed to be here ever. + def size # :nodoc: + size = 0 + @data.each_value do |v1| + v1.each_value do |v2| + v2.each_value do |v3| + v3.each_value do |v4| + size += v4.size + end + end + end + end + + size + @query_cache.size + end + private def canonical_no_templates(templates) -- cgit v1.2.3