Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…e store
  • Loading branch information...
commit 2401af4d6f76d0a2ebd8a39ed3e9efa60035cdf3 1 parent fd5c6e2
Jeremy Kemper jeremy authored
8 activesupport/lib/active_support/cache/memory_store.rb
@@ -19,6 +19,12 @@ def initialize
19 19 @data = {}
20 20 end
21 21
  22 + def read_multi(*names)
  23 + results = {}
  24 + names.each { |n| results[n] = read(n) }
  25 + results
  26 + end
  27 +
22 28 def read(name, options = nil)
23 29 super
24 30 @data[name]
@@ -39,7 +45,7 @@ def delete_matched(matcher, options = nil)
39 45 @data.delete_if { |k,v| k =~ matcher }
40 46 end
41 47
42   - def exist?(name,options = nil)
  48 + def exist?(name, options = nil)
43 49 super
44 50 @data.has_key?(name)
45 51 end
7 activesupport/test/caching_test.rb
@@ -168,6 +168,13 @@ def test_store_objects_should_be_immutable
168 168 assert_raise(ActiveSupport::FrozenObjectError) { @cache.read('foo').gsub!(/.*/, 'baz') }
169 169 assert_equal 'bar', @cache.read('foo')
170 170 end
  171 +
  172 + def test_multi_get
  173 + @cache.write('foo', 1)
  174 + @cache.write('goo', 2)
  175 + result = @cache.read_multi('foo', 'goo')
  176 + assert_equal({'foo' => 1, 'goo' => 2}, result)
  177 + end
171 178 end
172 179
173 180 uses_memcached 'memcached backed store' do

0 comments on commit 2401af4

Please sign in to comment.
Something went wrong with that request. Please try again.