mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
MemoryStore#read_multi(*keys) for dev-mode compatibility with memcache store
This commit is contained in:
parent
64373937a3
commit
03aa7877f7
2 changed files with 14 additions and 1 deletions
|
@ -21,6 +21,12 @@ module ActiveSupport
|
|||
@data = {}
|
||||
end
|
||||
|
||||
def read_multi(*names)
|
||||
results = {}
|
||||
names.each { |n| results[n] = read(n) }
|
||||
results
|
||||
end
|
||||
|
||||
def read(name, options = nil)
|
||||
super do
|
||||
@data[name]
|
||||
|
@ -45,7 +51,7 @@ module ActiveSupport
|
|||
end
|
||||
end
|
||||
|
||||
def exist?(name,options = nil)
|
||||
def exist?(name, options = nil)
|
||||
super do
|
||||
@data.has_key?(name)
|
||||
end
|
||||
|
|
|
@ -185,6 +185,13 @@ class MemoryStoreTest < ActiveSupport::TestCase
|
|||
@cache.write('foo', bar)
|
||||
assert_nothing_raised { bar.gsub!(/.*/, 'baz') }
|
||||
end
|
||||
|
||||
def test_multi_get
|
||||
@cache.write('foo', 1)
|
||||
@cache.write('goo', 2)
|
||||
result = @cache.read_multi('foo', 'goo')
|
||||
assert_equal({'foo' => 1, 'goo' => 2}, result)
|
||||
end
|
||||
end
|
||||
|
||||
uses_memcached 'memcached backed store' do
|
||||
|
|
Loading…
Reference in a new issue