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:
parent
3bd5342871
commit
5e21667496
2 changed files with 7 additions and 0 deletions
|
@ -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) }
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue