diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-06-28 14:26:57 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-28 14:26:57 -0400 |
commit | 8adef0b8336dfc9e75fe036f7957937bfaf6f2f4 (patch) | |
tree | a642f6e0f839e7fc7fdd8a64bb0be7a55dac5fd1 /activerecord/lib | |
parent | da5dbada0464a9f1d17154f1cf9e51029b3efa48 (diff) | |
parent | 1b4360dea81b0c04589a62b8af7c555cfc0509ca (diff) | |
download | rails-8adef0b8336dfc9e75fe036f7957937bfaf6f2f4.tar.gz rails-8adef0b8336dfc9e75fe036f7957937bfaf6f2f4.tar.bz2 rails-8adef0b8336dfc9e75fe036f7957937bfaf6f2f4.zip |
Merge pull request #29609 from tsukasaoishi/query_cache_from_beginning
Enable query cache if set a configurations
Diffstat (limited to 'activerecord/lib')
-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 ec246e97bc..e4c2e1f86f 100644 --- a/activerecord/lib/active_record/query_cache.rb +++ b/activerecord/lib/active_record/query_cache.rb @@ -5,20 +5,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 connected? - connection.cache(&block) - else + if configurations.empty? yield + else + connection.cache(&block) 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 connected? - connection.uncached(&block) - else + if configurations.empty? yield + else + connection.uncached(&block) end end end |