提交 324f1451 编写于 作者: J José Valim

Dump and load rack-cache stuff.

上级 b77e032c
......@@ -14,11 +14,15 @@ def initialize(store = RAILS_CACHE)
end
def read(key)
@store.read(key) || []
if data = @store.read(key)
Marshal.load(data)
else
[]
end
end
def write(key, value)
@store.write(key, value)
@store.write(key, Marshal.dump(value))
end
::Rack::Cache::MetaStore::RAILS = self
......
require 'abstract_unit'
require 'action_dispatch/http/rack_cache'
class RackCacheMetaStoreTest < ActiveSupport::TestCase
class ReadWriteHash < ::Hash
alias :read :[]
alias :write :[]=
end
setup do
@store = ActionDispatch::RailsMetaStore.new(ReadWriteHash.new)
end
test "stuff is deep duped" do
@store.write(:foo, { :bar => :original })
hash = @store.read(:foo)
hash[:bar] = :changed
hash = @store.read(:foo)
assert_equal :original, hash[:bar]
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册