diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2010-04-18 23:01:44 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2010-04-19 00:19:10 -0700 |
commit | 03aa7877f7b3a0eb5ed1bb48a30be74194c4177a (patch) | |
tree | c6dd0f37cdcbe9c43b199b492af7b902d4d98072 /activesupport | |
parent | 64373937a393518a6e6a63255176ca297d3c009e (diff) | |
download | rails-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.rb | 8 | ||||
-rw-r--r-- | activesupport/test/caching_test.rb | 7 |
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 |