Skip to content

Commit

Permalink
Use Redis#mget for RedisCacheStore#fetch_multi
Browse files Browse the repository at this point in the history
  • Loading branch information
fatkodima authored and jeremy committed Feb 5, 2018
1 parent c327f4d commit f45a3f8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions activesupport/lib/active_support/cache/redis_cache_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions activesupport/test/cache/stores/redis_cache_store_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f45a3f8

Please sign in to comment.