aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2010-04-18 23:01:44 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2010-04-19 00:19:10 -0700
commit03aa7877f7b3a0eb5ed1bb48a30be74194c4177a (patch)
treec6dd0f37cdcbe9c43b199b492af7b902d4d98072 /activesupport
parent64373937a393518a6e6a63255176ca297d3c009e (diff)
downloadrails-03aa7877f7b3a0eb5ed1bb48a30be74194c4177a.tar.gz
rails-03aa7877f7b3a0eb5ed1bb48a30be74194c4177a.tar.bz2
rails-03aa7877f7b3a0eb5ed1bb48a30be74194c4177a.zip
MemoryStore#read_multi(*keys) for dev-mode compatibility with memcache store
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/cache/memory_store.rb8
-rw-r--r--activesupport/test/caching_test.rb7
2 files changed, 14 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/cache/memory_store.rb b/activesupport/lib/active_support/cache/memory_store.rb
index e6085d97ec..379922f986 100644
--- a/activesupport/lib/active_support/cache/memory_store.rb
+++ b/activesupport/lib/active_support/cache/memory_store.rb
@@ -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
diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb
index d96f8e1de5..e62e7ef9aa 100644
--- a/activesupport/test/caching_test.rb
+++ b/activesupport/test/caching_test.rb
@@ -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