aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorYehuda Katz <wycats@gmail.com>2009-08-10 15:49:33 -0700
committerYehuda Katz <wycats@gmail.com>2009-08-11 15:03:53 -0700
commit4bf516e072f5279bdb462c6592e17b195fd9cf05 (patch)
treeedc9d70aaf470c86feebf1d7420f2a8a3cafcdc6 /activesupport
parent0adbeeb0c92c6de2e4a148e4b54d56cd4a325800 (diff)
downloadrails-4bf516e072f5279bdb462c6592e17b195fd9cf05.tar.gz
rails-4bf516e072f5279bdb462c6592e17b195fd9cf05.tar.bz2
rails-4bf516e072f5279bdb462c6592e17b195fd9cf05.zip
More perf work:
* Move #set_cookie and #delete_cookie inline to optimize. These optimizations should almost certainly be sent back upstream to Rack. The optimization involves using an ivar for cookies instead of indexing into the headers each time. * Was able to use a bare Hash for headers now that cookies have their own joining semantics (some code assumed that the raw cookies were an Array). * Cache blankness of body on body= * Improve expand_cache_key for Arrays of a single element (common in our case) * Use a simple layout condition check unless conditions are used * Cache visible actions * Lazily load the UrlRewriter * Make etag an ivar that is set on prepare!
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/cache.rb22
1 files changed, 15 insertions, 7 deletions
diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb
index 448db538ab..e28df8efa5 100644
--- a/activesupport/lib/active_support/cache.rb
+++ b/activesupport/lib/active_support/cache.rb
@@ -62,19 +62,27 @@ module ActiveSupport
end
end
+ RAILS_CACHE_ID = ENV["RAILS_CACHE_ID"]
+ RAILS_APP_VERION = ENV["RAILS_APP_VERION"]
+ EXPANDED_CACHE = RAILS_CACHE_ID || RAILS_APP_VERION
+
def self.expand_cache_key(key, namespace = nil)
expanded_cache_key = namespace ? "#{namespace}/" : ""
- if ENV["RAILS_CACHE_ID"] || ENV["RAILS_APP_VERSION"]
- expanded_cache_key << "#{ENV["RAILS_CACHE_ID"] || ENV["RAILS_APP_VERSION"]}/"
+ if EXPANDED_CACHE
+ expanded_cache_key << "#{RAILS_CACHE_ID || RAILS_APP_VERION}/"
end
- expanded_cache_key << case
- when key.respond_to?(:cache_key)
+ expanded_cache_key <<
+ if key.respond_to?(:cache_key)
key.cache_key
- when key.is_a?(Array)
- key.collect { |element| expand_cache_key(element) }.to_param
- when key
+ elsif key.is_a?(Array)
+ if key.size > 1
+ key.collect { |element| expand_cache_key(element) }.to_param
+ else
+ key.first.to_param
+ end
+ elsif key
key.to_param
end.to_s