diff options
author | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2018-02-17 17:25:08 +0900 |
---|---|---|
committer | Yuji Yaginuma <yuuji.yaginuma@gmail.com> | 2018-02-19 07:16:52 +0900 |
commit | 0d9fb7eb8df380b601d0a9a0a796b97e9c3c45c7 (patch) | |
tree | 50b4ff2cbf049fe2a8b303c53ed4832a2a6195e7 /activerecord/lib/active_record/query_cache.rb | |
parent | bec1751ee416aa5a36fd5d147abf97138a0d2efb (diff) | |
download | rails-0d9fb7eb8df380b601d0a9a0a796b97e9c3c45c7.tar.gz rails-0d9fb7eb8df380b601d0a9a0a796b97e9c3c45c7.tar.bz2 rails-0d9fb7eb8df380b601d0a9a0a796b97e9c3c45c7.zip |
Use the query cache when connection is already connected
Fixes #32021.
Diffstat (limited to 'activerecord/lib/active_record/query_cache.rb')
-rw-r--r-- | activerecord/lib/active_record/query_cache.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/query_cache.rb b/activerecord/lib/active_record/query_cache.rb index 8e23128333..c8e340712d 100644 --- a/activerecord/lib/active_record/query_cache.rb +++ b/activerecord/lib/active_record/query_cache.rb @@ -7,20 +7,20 @@ module ActiveRecord # Enable the query cache within the block if Active Record is configured. # If it's not, it will execute the given block. def cache(&block) - if configurations.empty? - yield - else + if connected? || !configurations.empty? connection.cache(&block) + else + yield end end # Disable the query cache within the block if Active Record is configured. # If it's not, it will execute the given block. def uncached(&block) - if configurations.empty? - yield - else + if connected? || !configurations.empty? connection.uncached(&block) + else + yield end end end |