Clearing ActiveRecord cache

前端 未结 4 1945
时光取名叫无心
时光取名叫无心 2021-02-04 00:02

I\'m building a command line application using ActiveRecord 3.0 (without rails). How do I clear the query cache that ActiveRecord maintains?

4条回答
  •  抹茶落季
    2021-02-04 00:45

    We use:

    ActiveRecord::Base.connection.query_cache.clear
    (ActiveRecord::Base.connection.tables - %w[schema_migrations versions]).each do |table|
      table.classify.constantize.reset_column_information rescue nil
    end
    

    But I am not certain even this is enough.

提交回复
热议问题