Skip to content

Commit

Permalink
Objects returned from MemoryStore cache should not be frozen, they sh…
Browse files Browse the repository at this point in the history
…ould be duplicates. This makes Rails.cache.read behave the same for MemoryStore as it does for MemCacheStore.
  • Loading branch information
scottwb committed Aug 7, 2010
1 parent bdbf727 commit 46f73da
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/cache/memory_store.rb
Expand Up @@ -27,7 +27,7 @@ def read_multi(*names)

def read(name, options = nil)
super
@data[name]
@data[name].duplicable? ? @data[name].dup : @data[name]
end

def write(name, value, options = nil)
Expand Down
2 changes: 1 addition & 1 deletion activesupport/test/caching_test.rb
Expand Up @@ -165,7 +165,7 @@ def setup

def test_store_objects_should_be_immutable
@cache.write('foo', 'bar')
assert_raise(ActiveSupport::FrozenObjectError) { @cache.read('foo').gsub!(/.*/, 'baz') }
@cache.read('foo').gsub!(/.*/, 'baz')
assert_equal 'bar', @cache.read('foo')
end

Expand Down

0 comments on commit 46f73da

Please sign in to comment.