mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fall back to #to_s for cache key expansion
This commit is contained in:
parent
72f93b581f
commit
f47c81ff37
2 changed files with 9 additions and 1 deletions
|
@ -19,7 +19,7 @@ module ActiveSupport
|
|||
|
||||
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"]}/"
|
||||
end
|
||||
|
@ -31,6 +31,8 @@ module ActiveSupport
|
|||
key.collect { |element| expand_cache_key(element) }.to_param
|
||||
when key.respond_to?(:to_param)
|
||||
key.to_param
|
||||
else
|
||||
key.to_s
|
||||
end
|
||||
|
||||
expanded_cache_key
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
require 'abstract_unit'
|
||||
|
||||
class CacheKeyTest < Test::Unit::TestCase
|
||||
def test_expand_cache_key
|
||||
assert_equal 'name/1/2/true', ActiveSupport::Cache.expand_cache_key([1, '2', true], :name)
|
||||
end
|
||||
end
|
||||
|
||||
class CacheStoreSettingTest < Test::Unit::TestCase
|
||||
def test_file_fragment_cache_store
|
||||
store = ActiveSupport::Cache.lookup_store :file_store, "/path/to/cache/directory"
|
||||
|
|
Loading…
Reference in a new issue