80d13e25f10f2d2b4a0fae55b1e09ca91ea9d260
5 module ActionController
#:nodoc:
6 # Caching is a cheap way of speeding up slow applications by keeping the result of calculations, renderings, and database calls
7 # around for subsequent requests. Action Controller affords you three approaches in varying levels of granularity: Page, Action, Fragment.
9 # You can read more about each approach and the sweeping assistance by clicking the modules below.
11 # Note: To turn off all caching and sweeping, set Base.perform_caching = false.
16 # All the caching stores from ActiveSupport::Cache is available to be used as backends for Action Controller caching. This setting only
17 # affects action and fragment caching as page caching is always written to disk.
19 # Configuration examples (MemoryStore is the default):
21 # ActionController::Base.cache_store = :memory_store
22 # ActionController::Base.cache_store = :file_store, "/path/to/cache/directory"
23 # ActionController::Base.cache_store = :drb_store, "druby://localhost:9192"
24 # ActionController::Base.cache_store = :mem_cache_store, "localhost"
25 # ActionController::Base.cache_store = MyOwnStore.new("parameter")
27 autoload
:Actions, 'action_controller/caching/actions'
28 autoload
:Fragments, 'action_controller/caching/fragments'
29 autoload
:Pages, 'action_controller/caching/pages'
30 autoload
:Sweeper, 'action_controller/caching/sweeping'
31 autoload
:Sweeping, 'action_controller/caching/sweeping'
33 def self.included(base
) #:nodoc:
36 cattr_reader
:cache_store
38 # Defines the storage option for cached fragments
39 def self.cache_store
=(store_option
)
40 @
@cache_store = ActiveSupport
::Cache.lookup_store(store_option
)
43 include Pages
, Actions
, Fragments
44 include Sweeping
if defined?(ActiveRecord
)
46 @
@perform_caching = true
47 cattr_accessor
:perform_caching
49 def self.cache_configured
?
50 perform_caching
&& cache_store
56 # Convenience accessor
57 def cache(key
, options
= {}, &block
)
59 cache_store
.fetch(ActiveSupport
::Cache.expand_cache_key(key
, :controller), options
, &block
)
67 self.class.cache_configured
?