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:
parent
3e2f0800e3
commit
29550cc91f
3 changed files with 14 additions and 0 deletions
|
@ -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')
|
||||
|
|
Loading…
Reference in a new issue