Ilan,
Thanks for your reply. Indeed, that''s exactly what one would expect:
to be able to set something in environment.rb (or in an environment-
specific file) such as:
config.active_record.query_cache_enabled = false
(That particular code fails with undefined method
`query_cache_enabled='' for ActiveRecord::Base:Class.)
When you peruse the code that does the query results caching, you
might think you could setup an initializer that does the following:
ActiveRecord::Base.connection.query_cache_enabled = false
Unfortunately, that also doesn''t work, because ActiveController
actually explicitly enables the query cache when calling an action in
action_controller/caching.rb:
module ActionController #:nodoc:
# ...
# Note: To turn off all caching and sweeping, set
Base.perform_caching = false.
module Caching
def self.included(base) #:nodoc:
base.class_eval do
include Pages, Actions, Fragments
if defined? ActiveRecord
include Sweeping, SqlCache
end
@@perform_caching = true
cattr_accessor :perform_caching
end
end ...
Where SqlCache looks like:
module SqlCache
def self.included(base) #:nodoc:
if defined?(ActiveRecord) && ActiveRecord::Base.respond_to?
(:cache)
base.alias_method_chain :perform_action, :caching
end
end
def perform_action_with_caching
ActiveRecord::Base.cache do
perform_action_without_caching
end
end
end
It''s the ActiveRecord::Base.cache call that explicitly turns on query
caching that was the remaining culprit for me.
Consequently, given no apparent alternative other than to turn off ALL
caching using ActionController::Base.perform_caching = false, I have
disincluded SqlCache from being included in my controller, and that
has effectively disabled query caching. It appears there is no
convenient way to selectively disable just query caching while
maintaining the other sorts of caching that Rails does for you. If
someone else has a Better Way (tm), please advise.
Michael
On Mar 17, 7:31 pm, Ilan Berci
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> mh wrote:
> > Ref my earlier post in this group regarding a problem with AR query
> > caching with MS SQL Server, I now find that the most convenient
> > solution would be simply disabling query caching globally for this
> > app.
>
> > Question is, how do you do that?
>
> all "global" settings should be in config/environment.rb or at
least
> loaded from there.. while you are in that file, check out the comments
> for a whole host of features that you can turn on and off (including
> caching I believe)
>
> hth
>
> ilan
>
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---