Merged updates from trunk into stable branch
[feedcatcher.git] / vendor / rails / activerecord / lib / active_record / query_cache.rb
1 module ActiveRecord
2 class QueryCache
3 module ClassMethods
4 # Enable the query cache within the block if Active Record is configured.
5 def cache(&block)
6 if ActiveRecord::Base.configurations.blank?
7 yield
8 else
9 connection.cache(&block)
10 end
11 end
12
13 # Disable the query cache within the block if Active Record is configured.
14 def uncached(&block)
15 if ActiveRecord::Base.configurations.blank?
16 yield
17 else
18 connection.uncached(&block)
19 end
20 end
21 end
22
23 def initialize(app)
24 @app = app
25 end
26
27 def call(env)
28 ActiveRecord::Base.cache do
29 @app.call(env)
30 end
31 end
32 end
33 end