From 390d285ef67e1868aa0af6e86fa1cd59c32e926d Mon Sep 17 00:00:00 2001 From: Mike Perham Date: Sat, 28 Aug 2010 14:46:15 -0700 Subject: Support pluggable cache stores. [#5486 state:committed] Signed-off-by: Jeremy Kemper --- activesupport/CHANGELOG | 10 ++++++++++ activesupport/lib/active_support/cache.rb | 9 ++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index c7f5d6f8b9..e1904fad39 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -1,3 +1,13 @@ +*Rails 3.0.0 (unreleased)* + +* Pluggable cache stores: setting config.cache_store = "custom_store" will require 'active_support/cache/custom_store' and look for the CustomStore constant. #5486 [Mike Perham] + + +*Rails 3.0.0 [release candidate 2] (August 23rd, 2010)* + +* No changes + + *Rails 3.0.0 [release candidate] (July 26th, 2010)* * Removed Object#returning, Object#tap should be used instead. [Santiago Pastorino] diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index 8153dd57de..df35540b55 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -58,7 +58,14 @@ module ActiveSupport case store when Symbol store_class_name = store.to_s.camelize - store_class = ActiveSupport::Cache.const_get(store_class_name) + store_class = + begin + require "active_support/cache/#{store}" + rescue LoadError + raise "Could not find cache store adapter for #{store} (#{$!})" + else + ActiveSupport::Cache.const_get(store_class_name) + end store_class.new(*parameters) when nil ActiveSupport::Cache::MemoryStore.new -- cgit v1.2.3