提交 8f2e3215 编写于 作者: J José Valim

Merge pull request #1608 from sishen/sishen

MemcacheStore: deserialize the entry reading from local_cache when using 
...@@ -183,6 +183,14 @@ def deserialize_entry(raw_value) ...@@ -183,6 +183,14 @@ def deserialize_entry(raw_value)
# Provide support for raw values in the local cache strategy. # Provide support for raw values in the local cache strategy.
module LocalCacheWithRaw # :nodoc: module LocalCacheWithRaw # :nodoc:
protected protected
def read_entry(key, options)
entry = super
if options[:raw] && local_cache && entry
entry = deserialize_entry(entry.value)
end
entry
end
def write_entry(key, entry, options) # :nodoc: def write_entry(key, entry, options) # :nodoc:
retval = super retval = super
if options[:raw] && local_cache && retval if options[:raw] && local_cache && retval
......
...@@ -636,6 +636,13 @@ def test_raw_values ...@@ -636,6 +636,13 @@ def test_raw_values
assert_equal "2", cache.read("foo") assert_equal "2", cache.read("foo")
end end
def test_raw_values_with_marshal
cache = ActiveSupport::Cache.lookup_store(:mem_cache_store, :raw => true)
cache.clear
cache.write("foo", Marshal.dump([]))
assert_equal [], cache.read("foo")
end
def test_local_cache_raw_values def test_local_cache_raw_values
cache = ActiveSupport::Cache.lookup_store(:mem_cache_store, :raw => true) cache = ActiveSupport::Cache.lookup_store(:mem_cache_store, :raw => true)
cache.clear cache.clear
...@@ -644,6 +651,15 @@ def test_local_cache_raw_values ...@@ -644,6 +651,15 @@ def test_local_cache_raw_values
assert_equal "2", cache.read("foo") assert_equal "2", cache.read("foo")
end end
end end
def test_local_cache_raw_values_with_marshal
cache = ActiveSupport::Cache.lookup_store(:mem_cache_store, :raw => true)
cache.clear
cache.with_local_cache do
cache.write("foo", Marshal.dump([]))
assert_equal [], cache.read("foo")
end
end
end end
end end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册