Permalink
Browse files

Add ability to get multiple memcached keys at the same time (via MemC…

…acheStore#read_multi).

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information...
1 parent 50608ec commit ad85771221f6a05b5eb89601bd5336bd15b8e1f8 Joe Van Dyk committed with jeremy Feb 3, 2009
@@ -43,6 +43,11 @@ def initialize(*addresses)
extend Strategy::LocalCache
end
+ # Reads multiple keys from the cache.
+ def read_multi(*keys)
+ @data.get_multi keys
+ end
+
def read(key, options = nil) # :nodoc:
super
@data.get(key, raw?(options))
No changes.
@@ -256,6 +256,15 @@ def test_exist_with_nulls_cached_locally
end
end
+ def test_multi_get
+ @cache.with_local_cache do
+ @cache.write('foo', 1)
+ @cache.write('goo', 2)
+ result = @cache.read_multi('foo', 'goo')
+ assert_equal({'foo' => 1, 'goo' => 2}, result)
+ end
+ end
+
def test_middleware
app = lambda { |env|
result = @cache.write('foo', 'bar')

0 comments on commit ad85771

Please sign in to comment.