From 6ef329d3250cfc3a21184cc2a8248aa18a1f6815 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Wed, 27 May 2009 14:54:58 -0500 Subject: Ensure Memcache local cache returns duplicated values [#2302 state:resolved] --- activesupport/lib/active_support/cache/strategy/local_cache.rb | 2 +- activesupport/test/caching_test.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/activesupport/lib/active_support/cache/strategy/local_cache.rb b/activesupport/lib/active_support/cache/strategy/local_cache.rb index 4bbcd8e4c4..3b5fccc737 100644 --- a/activesupport/lib/active_support/cache/strategy/local_cache.rb +++ b/activesupport/lib/active_support/cache/strategy/local_cache.rb @@ -45,7 +45,7 @@ module ActiveSupport elsif value.nil? value = super local_cache.write(key, value || NULL) if local_cache - value + value.duplicable? ? value.dup : value else # forcing the value to be immutable value.duplicable? ? value.dup : value diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb index bd237a5c8e..51d04d9388 100644 --- a/activesupport/test/caching_test.rb +++ b/activesupport/test/caching_test.rb @@ -180,6 +180,15 @@ uses_memcached 'memcached backed store' do end end + def test_stored_objects_should_not_be_frozen + @cache.with_local_cache do + @cache.write('foo', 'bar') + end + @cache.with_local_cache do + assert !@cache.read('foo').frozen? + end + end + def test_write_should_return_true_on_success @cache.with_local_cache do result = @cache.write('foo', 'bar') -- cgit v1.2.3