I'm building a command line application using ActiveRecord 3.0 (without rails). How do I clear the query cache that ActiveRecord maintains?
相关问题
- How to specify memcache server to Rack::Session::M
- Why am I getting a “C compiler cannot create execu
- reference to a method?
- ruby 1.9 wrong file encoding on windows
- gem cleanup shows error: Unable to uninstall bundl
相关文章
- Ruby using wrong version of openssl
- Difference between Thread#run and Thread#wakeup?
- how to call a active record named scope with a str
- “No explicit conversion of Symbol into String” for
- Segmentation fault with ruby 2.0.0p247 leading to
- How to detect if an element exists in Watir
- uninitialized constant Mysql2::Client::SECURE_CONN
- Is there a google API to read cached content? [clo
We use:
But I am not certain even this is enough.
Have a look at the method
clear_query_cache
in http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/QueryCache.htmlOftentimes when you see caching of database queries, your db is doing the caching, not ActiveRecord, which means you need to clear the cache and buffers at the db level, not the ActiveRecord level.
For example, to clear Postgres' cache and buffers on Mac, you would do
sudo purge
, which forces the disk cache to be flushed and emptied.To clear Postgres' cache and buffers on Linux, you would shut down postgres, drop the caches, and start postgres back up again:
Further reading:
To a first approximation: