1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add ability to get multiple memcached keys at the same time (via MemCacheStore#read_multi).

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
This commit is contained in:
Joe Van Dyk 2009-02-02 16:43:14 -08:00 committed by Jeremy Kemper
parent 3e2f0800e3
commit 29550cc91f
3 changed files with 14 additions and 0 deletions

View file

@ -43,6 +43,11 @@ module ActiveSupport
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))

View file

View file

@ -251,6 +251,15 @@ uses_memcached 'memcached backed store' do
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')