aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib
diff options
context:
space:
mode:
Diffstat (limited to 'actionview/lib')
-rw-r--r--actionview/lib/action_view/digestor.rb13
-rw-r--r--actionview/lib/action_view/lookup_context.rb16
2 files changed, 19 insertions, 10 deletions
diff --git a/actionview/lib/action_view/digestor.rb b/actionview/lib/action_view/digestor.rb
index ad6c65c436..07600f2092 100644
--- a/actionview/lib/action_view/digestor.rb
+++ b/actionview/lib/action_view/digestor.rb
@@ -4,13 +4,11 @@ require 'monitor'
module ActionView
class Digestor
- cattr_reader(:cache)
- @@cache = Concurrent::Map.new
@@digest_mutex = Mutex.new
class PerRequestDigestCacheExpiry < Struct.new(:app) # :nodoc:
def call(env)
- ActionView::Digestor.cache.clear
+ ActionView::LookupContext::DetailsKey.clear
app.call(env)
end
end
@@ -24,13 +22,13 @@ module ActionView
# * <tt>partial</tt> - Specifies whether the template is a partial
def digest(name:, finder:, dependencies: [])
dependencies ||= []
- cache_key = ([ name, finder.details_key.hash ].compact + dependencies).join('.')
+ cache_key = ([ name ].compact + dependencies).join('.')
# this is a correctly done double-checked locking idiom
# (Concurrent::Map's lookups have volatile semantics)
- @@cache[cache_key] || @@digest_mutex.synchronize do
- @@cache.fetch(cache_key) do # re-check under lock
- @@cache[cache_key] = tree(name, finder, dependencies).digest
+ finder.digest_cache[cache_key] || @@digest_mutex.synchronize do
+ finder.digest_cache.fetch(cache_key) do # re-check under lock
+ finder.digest_cache[cache_key] = tree(name, finder, dependencies).digest
end
end
end
@@ -50,6 +48,7 @@ module ActionView
if node = seen[template.identifier] # handle cycles in the tree
node
else
+
node = seen[template.identifier] = Node.create(name, logical_name, template, partial)
deps = DependencyTracker.find_dependencies(name, template, finder.view_paths)
diff --git a/actionview/lib/action_view/lookup_context.rb b/actionview/lib/action_view/lookup_context.rb
index 126f289f55..86afedaa2d 100644
--- a/actionview/lib/action_view/lookup_context.rb
+++ b/actionview/lib/action_view/lookup_context.rb
@@ -55,9 +55,7 @@ module ActionView
class DetailsKey #:nodoc:
alias :eql? :equal?
- alias :object_hash :hash
- attr_reader :hash
@details_keys = Concurrent::Map.new
def self.get(details)
@@ -72,8 +70,16 @@ module ActionView
@details_keys.clear
end
+ def self.empty?; @details_keys.empty?; end
+
+ def self.digest_caches
+ @details_keys.values.map(&:digest_cache)
+ end
+
+ attr_reader :digest_cache
+
def initialize
- @hash = object_hash
+ @digest_cache = Concurrent::Map.new
end
end
@@ -200,6 +206,10 @@ module ActionView
self.view_paths = view_paths
end
+ def digest_cache
+ details_key.digest_cache
+ end
+
def initialize_details(target, details)
registered_details.each do |k|
target[k] = details[k] || Accessors::DEFAULT_PROCS[k].call