Skip to content
Browse files

Improved the speed of regular expression expirations for caching by a…

… factor of 10 #1221 [Jamis Buck]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1248 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent be27caf commit 5640f76970c9b68f74df9da5cfa9763833e00d78 @dhh dhh committed
Showing with 12 additions and 13 deletions.
  1. +2 −0 actionpack/CHANGELOG
  2. +10 −13 actionpack/lib/action_controller/caching.rb
View
2 actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Improved the speed of regular expression expirations for caching by a factor of 10 #1221 [Jamis Buck]
+
* Removed dumping of template assigns on the rescue page as it would very easily include a ton of data making page loads take seconds (and the information was rarely helpful) #1222
* Added BenchmarkHelper that can measure the execution time of a block in a template and reports the result to the log. Example:
View
23 actionpack/lib/action_controller/caching.rb
@@ -368,8 +368,8 @@ def delete(name, options) #:nodoc:
end
def delete_matched(matcher, options) #:nodoc:
- search_dir(@cache_path).each do |f|
- File.delete(f) if f =~ matcher && File.exist?(f)
+ search_dir(@cache_path) do |f|
+ File.delete(f) rescue nil if f =~ matcher
end
end
@@ -382,19 +382,16 @@ def ensure_cache_path(path)
FileUtils.makedirs(path) unless File.exists?(path)
end
- def search_dir(dir)
- require 'pathname'
- files = []
- dir = Dir.new(dir)
- dir.each do |d|
- unless d == '.' or d == '..'
- d = File.join(dir.path, d)
- p = Pathname.new(d)
- files << p.to_s if p.file?
- files += search_dir(d) if p.directory?
+ def search_dir(dir, &callback)
+ Dir.foreach(dir) do |d|
+ next if d == "." || d == ".."
+ name = File.join(dir, d)
+ if File.directory?(name)
+ search_dir(name, &callback)
+ else
+ callback.call name
end
end
- files
end
end
end

0 comments on commit 5640f76

Please sign in to comment.
Something went wrong with that request. Please try again.