Use Redis#mget for RedisCacheStore#fetch_multi

This commit is contained in:
fatkodima 2018-02-05 17:22:18 +02:00 committed by Jeremy Daer
parent 3b5d940fe5
commit 83c1ed9a1a
2 changed files with 16 additions and 0 deletions

View File

@ -307,6 +307,14 @@ module ActiveSupport
end
end
def read_multi_entries(names, _options)
if mget_capable?
read_multi_mget(*names)
else
super
end
end
def read_multi_mget(*names)
options = names.extract_options!
options = merged_options(options)

View File

@ -109,6 +109,14 @@ module ActiveSupport::Cache::RedisCacheStoreTests
include CacheIncrementDecrementBehavior
include CacheInstrumentationBehavior
include AutoloadingCacheBehavior
def test_fetch_multi_uses_redis_mget
assert_called(@cache.redis, :mget, returns: []) do
@cache.fetch_multi("a", "b", "c") do |key|
key * 2
end
end
end
end
# Separate test class so we can omit the namespace which causes expected,