I'm building a command line application using ActiveRecord 3.0 (without rails). How do I clear the query cache that ActiveRecord maintains?
ActiveRecord makes accessing your database easy, but it can also help make it faster by its intelligent use of caching.
clear will clear your app cache. In that case rake tmp:cache:clear will just try to remove files from "#{Rails. root}/tmp/cache" but probably won't actually do anything since nothing is probably being cached on the filesystem.
ActiveRecord::Base indicates that the ActiveRecord class or module has a static inner class called Base that you're extending.
One of the primary aspects of ActiveRecord is that there is very little to no configuration needed. It follow convention over configuration. ActiveRecord is commonly used with the Ruby-on-Rails framework but you can use it with Sinatra or without any web framework if desired.
To a first approximation:
ActiveRecord::Base.connection.query_cache.clear
Have a look at the method clear_query_cache
in http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/QueryCache.html
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