Skip to content

Commit

Permalink
Only dup local cache values if duplicable [#1653 state:resolved]
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Jan 29, 2009
1 parent a1a9889 commit 2e69db1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Expand Up @@ -41,7 +41,7 @@ def read(key, options = nil)
value
else
# forcing the value to be immutable
value.dup
value.duplicable? ? value.dup : value
end
end

Expand Down
12 changes: 12 additions & 0 deletions activesupport/test/caching_test.rb
Expand Up @@ -81,6 +81,11 @@ def test_should_read_and_write_hash
assert_equal({:a => "b"}, @cache.read('foo'))
end

def test_should_read_and_write_integer
@cache.write('foo', 1)
assert_equal 1, @cache.read('foo')
end

def test_should_read_and_write_nil
@cache.write('foo', nil)
assert_equal nil, @cache.read('foo')
Expand Down Expand Up @@ -200,6 +205,13 @@ def test_local_cache_of_read_and_write
end
end

def test_local_cache_should_read_and_write_integer
@cache.with_local_cache do
@cache.write('foo', 1)
assert_equal 1, @cache.read('foo')
end
end

def test_local_cache_of_delete
@cache.with_local_cache do
@cache.write('foo', 'bar')
Expand Down

0 comments on commit 2e69db1

Please sign in to comment.