mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04: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:
committed by
Jeremy Kemper
parent
3e2f0800e3
commit
29550cc91f
@@ -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))
|
||||
|
||||
0
activesupport/memcached_get_multi.diff
Normal file
0
activesupport/memcached_get_multi.diff
Normal 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')
|
||||
|
||||
Reference in New Issue
Block a user