aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2008-09-10 19:05:53 -0500
committerJoshua Peek <josh@joshpeek.com>2008-09-10 19:05:53 -0500
commit70a4f6c2dd66d855ff66a176076ad45caf3ed6ab (patch)
tree5533af503e8bbc4c9562906dd7b3ed6ec2c88191 /actionpack/lib
parent2ba9ca95f99c14cd95e90b7bb172ebb29ab25a72 (diff)
downloadrails-70a4f6c2dd66d855ff66a176076ad45caf3ed6ab.tar.gz
rails-70a4f6c2dd66d855ff66a176076ad45caf3ed6ab.tar.bz2
rails-70a4f6c2dd66d855ff66a176076ad45caf3ed6ab.zip
Switched computed public paths cache over to a simple hash w/ mutex
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helper.rb32
1 files changed, 17 insertions, 15 deletions
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
index ed33f082b9..a926599e25 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -463,7 +463,8 @@ module ActionView
end
private
- COMPUTED_PUBLIC_PATHS = ActiveSupport::Cache::MemoryStore.new.silence!
+ COMPUTED_PUBLIC_PATHS = {}
+ COMPUTED_PUBLIC_PATHS_GUARD = Mutex.new
# Add the the extension +ext+ if not present. Return full URLs otherwise untouched.
# Prefix with <tt>/dir/</tt> if lacking a leading +/+. Account for relative URL
@@ -483,23 +484,24 @@ module ActionView
dir, source, ext, include_host ].join
end
- source = COMPUTED_PUBLIC_PATHS.fetch(cache_key) do
- begin
- source += ".#{ext}" if ext && File.extname(source).blank? || File.exist?(File.join(ASSETS_DIR, dir, "#{source}.#{ext}"))
-
- if source =~ %r{^[-a-z]+://}
- source
- else
- source = "/#{dir}/#{source}" unless source[0] == ?/
- if has_request
- unless source =~ %r{^#{ActionController::Base.relative_url_root}/}
- source = "#{ActionController::Base.relative_url_root}#{source}"
+ COMPUTED_PUBLIC_PATHS_GUARD.synchronize do
+ source = COMPUTED_PUBLIC_PATHS[cache_key] ||=
+ begin
+ source += ".#{ext}" if ext && File.extname(source).blank? || File.exist?(File.join(ASSETS_DIR, dir, "#{source}.#{ext}"))
+
+ if source =~ %r{^[-a-z]+://}
+ source
+ else
+ source = "/#{dir}/#{source}" unless source[0] == ?/
+ if has_request
+ unless source =~ %r{^#{ActionController::Base.relative_url_root}/}
+ source = "#{ActionController::Base.relative_url_root}#{source}"
+ end
end
- end
- rewrite_asset_path(source)
+ rewrite_asset_path(source)
+ end
end
- end
end
if include_host && source !~ %r{^[-a-z]+://}