Permalink
Browse files

Only dup local cache values if duplicable [#1653 state:resolved]

  • Loading branch information...
josh committed Jan 29, 2009
1 parent a1a9889 commit 2e69db18ce2815c25eee64fc2978e7f6b57f6e1f
@@ -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
@@ -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')
@@ -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')

0 comments on commit 2e69db1

Please sign in to comment.