1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Redis fetch without names returns {}

When trying to call mget in Redis without any
parameters, a Redis error is thrown. To avoid
this, we circumvent Redis entirely when there
are no key names given.
This commit is contained in:
David Verhasselt 2019-04-12 15:40:29 +03:00
parent 3bd5342871
commit 5e21667496
2 changed files with 7 additions and 0 deletions

View file

@ -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) }

View file

@ -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