Class: ActiveRecord::Turntable::QueryCache
- Inherits:
-
QueryCache
- Object
- QueryCache
- ActiveRecord::Turntable::QueryCache
- Defined in:
- lib/active_record/turntable/query_cache.rb
Class Method Summary collapse
- .complete(enabled) ⇒ Object
- .install_executor_hooks(executor = ActiveSupport::Executor) ⇒ Object
- .run ⇒ Object
Class Method Details
.complete(enabled) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/active_record/turntable/query_cache.rb', line 19 def self.complete(enabled) klasses = ActiveRecord::Base.turntable_connections.values klasses.each do |k| k.connection.clear_query_cache k.connection.disable_query_cache! unless enabled end end |
.install_executor_hooks(executor = ActiveSupport::Executor) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/active_record/turntable/query_cache.rb', line 27 def self.install_executor_hooks(executor = ActiveSupport::Executor) executor.register_hook(self) executor.to_complete do klasses = ActiveRecord::Base.turntable_connection_classes klasses.each do |k| unless k.connected? && k.connection.transaction_open? k.clear_active_connections! end end end end |
.run ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/active_record/turntable/query_cache.rb', line 7 def self.run klasses = ActiveRecord::Base.turntable_connections.values enables = klasses.map do |k| enabled = k.connection.query_cache_enabled k.connection.enable_query_cache! enabled end enables.all? end |