Is there any way to turn off Rails' SQL query caching globally? Or, at the very least, not use it when i enter a transaction block?
Also, does sql query caching only apply to controller actions, or also to rake tasks or background daemons that i write that include Rails and use my models?
Got it! In application.rb:
config.middleware.delete ActiveRecord::QueryCache
In Rails 5 we can disable active record query cache using the given function as a middleware.
In application_controller.rb add the given code.
around_action :disable_query_cache
def disable_query_cache
ActiveRecord::Base.uncached do
yield
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With