Permalink
Browse files

MemoryStore#read_multi(*keys) for dev-mode compatibility with memcach…

…e store
  • Loading branch information...
jeremy committed Apr 19, 2010
1 parent fd5c6e2 commit 2401af4d6f76d0a2ebd8a39ed3e9efa60035cdf3
Showing with 14 additions and 1 deletion.
  1. +7 −1 activesupport/lib/active_support/cache/memory_store.rb
  2. +7 −0 activesupport/test/caching_test.rb
@@ -19,6 +19,12 @@ def initialize
@data = {}
end
+ def read_multi(*names)
+ results = {}
+ names.each { |n| results[n] = read(n) }
+ results
+ end
+
def read(name, options = nil)
super
@data[name]
@@ -39,7 +45,7 @@ def delete_matched(matcher, options = nil)
@data.delete_if { |k,v| k =~ matcher }
end
- def exist?(name,options = nil)
+ def exist?(name, options = nil)
super
@data.has_key?(name)
end
@@ -168,6 +168,13 @@ def test_store_objects_should_be_immutable
assert_raise(ActiveSupport::FrozenObjectError) { @cache.read('foo').gsub!(/.*/, 'baz') }
assert_equal 'bar', @cache.read('foo')
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

0 comments on commit 2401af4

Please sign in to comment.