diff --git a/activesupport/lib/active_support/cache/redis_cache_store.rb b/activesupport/lib/active_support/cache/redis_cache_store.rb index c21ade86709a139691ca410387b51d0e19f1afc5..af14c284082771f8e214f74b96a0d6522cb65b0f 100644 --- a/activesupport/lib/active_support/cache/redis_cache_store.rb +++ b/activesupport/lib/active_support/cache/redis_cache_store.rb @@ -307,6 +307,14 @@ def read_entry(key, options = nil) 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) diff --git a/activesupport/test/cache/stores/redis_cache_store_test.rb b/activesupport/test/cache/stores/redis_cache_store_test.rb index 22b519daf11554e9a20c89bac4292faac43055be..9daa0b87969379ac3b7985e2d335adfa2e4b2741 100644 --- a/activesupport/test/cache/stores/redis_cache_store_test.rb +++ b/activesupport/test/cache/stores/redis_cache_store_test.rb @@ -109,6 +109,14 @@ class RedisCacheStoreCommonBehaviorTest < StoreTest 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,