aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2008-01-03 21:05:12 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2008-01-03 21:05:12 +0000
commit2a9ad9ccbc706e546bf02ec95f864944e7d7983b (patch)
tree868624e91f037840bfbf0aca30bb2ea1c9d78701 /railties/lib
parent288553540b5b2f37497cb19357b25ac12e0498fd (diff)
downloadrails-2a9ad9ccbc706e546bf02ec95f864944e7d7983b.tar.gz
rails-2a9ad9ccbc706e546bf02ec95f864944e7d7983b.tar.bz2
rails-2a9ad9ccbc706e546bf02ec95f864944e7d7983b.zip
Moved the caching stores from ActionController::Caching::Fragments::* to ActiveSupport::Cache::*. If you're explicitly referring to a store, like ActionController::Caching::Fragments::MemoryStore, you need to update that reference with ActiveSupport::Cache::MemoryStore [DHH] Deprecated ActionController::Base.fragment_cache_store for ActionController::Base.cache_store [DHH] All fragment cache keys are now by default prefixed with the 'views/' namespace [DHH] Added ActiveRecord::Base.cache_key to make it easier to cache Active Records in combination with the new ActiveSupport::Cache::* libraries [DHH] Added ActiveSupport::Gzip.decompress/compress(source) as an easy wrapper for Zlib [Tobias Luetke] Included MemCache-Client to make the improved ActiveSupport::Cache::MemCacheStore work out of the box [Bob Cottrell, Eric Hodel] Added config.cache_store to environment options to control the default cache store (default is FileStore if tmp/cache is present, otherwise MemoryStore is used) [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8546 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/initializer.rb63
1 files changed, 33 insertions, 30 deletions
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb
index 5aed10afb5..c3056c196d 100644
--- a/railties/lib/initializer.rb
+++ b/railties/lib/initializer.rb
@@ -58,29 +58,7 @@ module Rails
end
# Sequentially step through all of the available initialization routines,
- # in order:
- #
- # * #check_ruby_version
- # * #set_load_path
- # * #require_frameworks
- # * #set_autoload_paths
- # * add_plugin_load_paths
- # * #load_environment
- # * #initialize_encoding
- # * #initialize_database
- # * #initialize_logger
- # * #initialize_framework_logging
- # * #initialize_framework_views
- # * #initialize_dependency_mechanism
- # * #initialize_whiny_nils
- # * #initialize_temporary_directories
- # * #initialize_framework_settings
- # * #add_support_load_paths
- # * #load_plugins
- # * #load_observers
- # * #initialize_routing
- # * #after_initialize
- # * #load_application_initializers
+ # in order (view execution order in source).
def process
check_ruby_version
set_load_path
@@ -92,12 +70,17 @@ module Rails
initialize_encoding
initialize_database
+
+ initialize_cache
+ initialize_framework_caches
+
initialize_logger
initialize_framework_logging
+
initialize_framework_views
initialize_dependency_mechanism
initialize_whiny_nils
- initialize_temporary_directories
+ initialize_temporary_session_directory
initialize_framework_settings
add_support_load_paths
@@ -239,6 +222,18 @@ module Rails
end
end
+ def initialize_cache
+ unless defined?(RAILS_CACHE)
+ silence_warnings { Object.const_set "RAILS_CACHE", ActiveSupport::Cache.lookup_store(configuration.cache_store) }
+ end
+ end
+
+ def initialize_framework_caches
+ if configuration.frameworks.include?(:action_controller)
+ ActionController::Base.cache_store ||= RAILS_CACHE
+ end
+ end
+
# If the +RAILS_DEFAULT_LOGGER+ constant is already set, this initialization
# routine does nothing. If the constant is not set, and Configuration#logger
# is not +nil+, this also does nothing. Otherwise, a new logger instance
@@ -277,6 +272,8 @@ module Rails
for framework in ([ :active_record, :action_controller, :action_mailer ] & configuration.frameworks)
framework.to_s.camelize.constantize.const_get("Base").logger ||= RAILS_DEFAULT_LOGGER
end
+
+ RAILS_CACHE.logger ||= RAILS_DEFAULT_LOGGER
end
# Sets +ActionController::Base#view_paths+ and +ActionMailer::Base#template_root+
@@ -309,15 +306,10 @@ module Rails
require('active_support/whiny_nil') if configuration.whiny_nils
end
- def initialize_temporary_directories
+ def initialize_temporary_session_directory
if configuration.frameworks.include?(:action_controller)
session_path = "#{configuration.root_path}/tmp/sessions/"
ActionController::Base.session_options[:tmpdir] = File.exist?(session_path) ? session_path : Dir::tmpdir
-
- cache_path = "#{configuration.root_path}/tmp/cache/"
- if File.exist?(cache_path)
- ActionController::Base.fragment_cache_store = :file_store, cache_path
- end
end
end
@@ -418,6 +410,9 @@ module Rails
# used directly.
attr_accessor :logger
+ # The specific cache store to use. By default, the ActiveSupport::Cache::Store will be used.
+ attr_accessor :cache_store
+
# The root of the application's views. (Defaults to <tt>app/views</tt>.)
attr_accessor :view_path
@@ -647,6 +642,14 @@ module Rails
def default_plugin_loader
Plugin::Loader
end
+
+ def default_cache_store
+ if File.exist?("#{root_path}/tmp/cache/")
+ [ :file_store, "#{root_path}/tmp/cache/" ]
+ else
+ :memory_store
+ end
+ end
end
end