Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 37 lines (32 sloc) 0.797 kb
76f024a Xavier Noria adds missing requires for Object#blank? and Object#present?
fxn authored
1 require 'active_support/core_ext/object/blank'
2
cce294f David Heinemeier Hansson Started work on a per-request query cache
dhh authored
3 module ActiveRecord
2b7f084 Rizwan Reza Adds basic description and title.
rizwanreza authored
4 # = Active Record Query Cache
aa002c0 Joshua Peek ActiveRecord::QueryCache middleware
josh authored
5 class QueryCache
6 module ClassMethods
7 # Enable the query cache within the block if Active Record is configured.
8 def cache(&block)
9 if ActiveRecord::Base.configurations.blank?
10 yield
11 else
12 connection.cache(&block)
13 end
f425bba Jeremy Kemper Use the query cache iff Active Record is configured.
jeremy authored
14 end
aa002c0 Joshua Peek ActiveRecord::QueryCache middleware
josh authored
15
16 # Disable the query cache within the block if Active Record is configured.
17 def uncached(&block)
18 if ActiveRecord::Base.configurations.blank?
19 yield
20 else
21 connection.uncached(&block)
22 end
23 end
24 end
25
26 def initialize(app)
27 @app = app
bfb906a Jeremy Kemper Speed up and simplify query caching.
jeremy authored
28 end
f425bba Jeremy Kemper Use the query cache iff Active Record is configured.
jeremy authored
29
aa002c0 Joshua Peek ActiveRecord::QueryCache middleware
josh authored
30 def call(env)
31 ActiveRecord::Base.cache do
32 @app.call(env)
7117fdb Jeremy Kemper r3616@asus: jeremy | 2005-09-26 23:09:28 -0700
jeremy authored
33 end
cce294f David Heinemeier Hansson Started work on a per-request query cache
dhh authored
34 end
bfb906a Jeremy Kemper Speed up and simplify query caching.
jeremy authored
35 end
cce294f David Heinemeier Hansson Started work on a per-request query cache
dhh authored
36 end
Something went wrong with that request. Please try again.