diff options
author | George Claghorn <george@basecamp.com> | 2019-04-14 13:20:34 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-14 13:20:34 -0400 |
commit | 1e4b959c5ead67c97941ba59c1e4ec4958010066 (patch) | |
tree | 36230158640538c5403198fdca9e01412f358275 | |
parent | f480cfabcd9000b5817b610e21466299025b12d2 (diff) | |
parent | 5e21667496ded39e575640dcebe21cacd2e04ef6 (diff) | |
download | rails-1e4b959c5ead67c97941ba59c1e4ec4958010066.tar.gz rails-1e4b959c5ead67c97941ba59c1e4ec4958010066.tar.bz2 rails-1e4b959c5ead67c97941ba59c1e4ec4958010066.zip |
Merge pull request #35951 from dv/fix-redis-fetch-multi-without-names
Make `Redis.cache.fetch_multi([])` not throw an error
-rw-r--r-- | activesupport/lib/active_support/cache/redis_cache_store.rb | 1 | ||||
-rw-r--r-- | activesupport/test/cache/stores/redis_cache_store_test.rb | 6 |
2 files changed, 7 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/cache/redis_cache_store.rb b/activesupport/lib/active_support/cache/redis_cache_store.rb index 9a55e49e27..87f9aa5346 100644 --- a/activesupport/lib/active_support/cache/redis_cache_store.rb +++ b/activesupport/lib/active_support/cache/redis_cache_store.rb @@ -361,6 +361,7 @@ module ActiveSupport def read_multi_mget(*names) options = names.extract_options! options = merged_options(options) + return {} if names == [] keys = names.map { |name| normalize_key(name, options) } diff --git a/activesupport/test/cache/stores/redis_cache_store_test.rb b/activesupport/test/cache/stores/redis_cache_store_test.rb index 1d87f74347..790534cd3c 100644 --- a/activesupport/test/cache/stores/redis_cache_store_test.rb +++ b/activesupport/test/cache/stores/redis_cache_store_test.rb @@ -140,6 +140,12 @@ module ActiveSupport::Cache::RedisCacheStoreTests end end + def test_fetch_multi_without_names + assert_not_called(@cache.redis, :mget) do + @cache.fetch_multi() { } + end + end + def test_increment_expires_in assert_called_with @cache.redis, :incrby, [ "#{@namespace}:foo", 1 ] do assert_called_with @cache.redis, :expire, [ "#{@namespace}:foo", 60 ] do |