File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
activerecord/lib/active_record Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -26,26 +26,30 @@ def uncached(&block)
26
26
end
27
27
28
28
def self . run
29
+ pools = [ ]
30
+
29
31
if ActiveRecord ::Base . legacy_connection_handling
30
- ActiveRecord ::Base . connection_handlers . each_value do |handler |
31
- handler . connection_pool_list . each ( & : enable_query_cache!)
32
+ ActiveRecord ::Base . connection_handlers . each do |key , handler |
33
+ pools . concat ( handler . connection_pool_list . each { | p | p . enable_query_cache! } )
32
34
end
33
35
else
34
- ActiveRecord ::Base . connection_handler . all_connection_pools . each ( & : enable_query_cache!)
36
+ pools . concat ( ActiveRecord ::Base . connection_handler . all_connection_pools . each { | p | p . enable_query_cache! } )
35
37
end
38
+
39
+ pools
36
40
end
37
41
38
- def self . complete ( _ )
42
+ def self . complete ( pools )
43
+ pools . each { |pool | pool . disable_query_cache! }
44
+
39
45
if ActiveRecord ::Base . legacy_connection_handling
40
- ActiveRecord ::Base . connection_handlers . each_value do |handler |
46
+ ActiveRecord ::Base . connection_handlers . each do |_ , handler |
41
47
handler . connection_pool_list . each do |pool |
42
- pool . disable_query_cache!
43
48
pool . release_connection if pool . active_connection? && !pool . connection . transaction_open?
44
49
end
45
50
end
46
51
else
47
52
ActiveRecord ::Base . connection_handler . all_connection_pools . each do |pool |
48
- pool . disable_query_cache!
49
53
pool . release_connection if pool . active_connection? && !pool . connection . transaction_open?
50
54
end
51
55
end
You can’t perform that action at this time.
0 commit comments