mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
dc4eec1129
commite6afd8b273
Author: Xavier Noria <fxn@hashref.com> Date: Thu May 8 23:49:36 2008 +0200 Overall documentation improvement and markup corrections. Zillion changes. commit2fead68b31
Author: Austin Putman <austin@emmanuel.local> Date: Wed May 7 19:35:46 2008 -0700 Documented class methods on ActionController::Routing. These are dangerous, and mostly used for testing. commitf5b84182db
Author: Teflon Ted <github@rudiment.net> Date: Wed May 7 16:08:49 2008 -0400 Added explanation about errant inflections not being patched in the future in order to avoid breaking legacy applications. commit370f4f5172
Author: Sunny Ripert <negatif@gmail.com> Date: Wed May 7 14:00:59 2008 +0200 Applied list conventions in AR::Base commit5bd18429f0
Author: Sunny Ripert <negatif@gmail.com> Date: Wed May 7 13:53:35 2008 +0200 Renamed Options list to Attributes list whenever they weren't option hashes in AR::Base commitd912bd5672
Author: Yaroslav Markin <yaroslav@markin.net> Date: Wed May 7 13:50:28 2008 +0400 Add a filter_parameter_logging usage hint to generated ApplicationController. This may help to remind the developer to filter sensitive information from application logs. Closes #11578 commitb243de0db3
Author: Jack Danger Canty <git@6brand.com> Date: Tue May 6 23:39:47 2008 -0700 doc: disambiguating an example ActiveRecord class commitf81d771f06
Author: Jack Danger Canty <git@6brand.com> Date: Tue May 6 23:35:05 2008 -0700 doc: ActiveRecord::Reflection::AssociationReflection#through_reflection Added documentation demonstrating the use of #through_reflection for finding intervening reflection objects for HasManyThrough and HasOneThrough. commitae6b46f00b
Author: Cheah Chu Yeow <chuyeow@gmail.com> Date: Wed May 7 13:47:41 2008 +0800 Document AttributeAssignmentError and MultiparameterAssignmentErrors. commit8f463550b5
Author: John Barnette <jbarnette@gmail.com> Date: Tue May 6 22:46:44 2008 -0700 Killing/fixing a bunch of outdated language in the AR README. commitaca44bcd92
Author: Cheah Chu Yeow <chuyeow@gmail.com> Date: Wed May 7 13:34:52 2008 +0800 Make a note about ActiveResource::Timeouterror being raised when ARes calls timeout. commit284a930a93
Author: Jonathan Dance <jd@wuputah.com> Date: Tue May 6 14:58:26 2008 -0400 improvements to the page caching docs commit9482da6213
Author: Sunny Ripert <negatif@gmail.com> Date: Mon May 5 18:13:40 2008 +0200 validates_numericality_of() "integer" option really is "only_integer" commite9afd6790a
Author: Sunny Ripert <negatif@gmail.com> Date: Mon May 5 12:11:59 2008 +0200 Harmonized hash notation in AR::Base commit67ebf14a91
Author: Sunny Ripert <negatif@gmail.com> Date: Mon May 5 12:06:19 2008 +0200 Turned options into rdoc-lists in AR::Base commit0ec7c0a41d
Author: Marshall Huss <mwhuss@Macbook.local> Date: Sun May 4 23:21:33 2008 -0400 Added information of how to set element_name in the case the user has a name confliction with an existing model Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
72 lines
No EOL
2.4 KiB
Ruby
72 lines
No EOL
2.4 KiB
Ruby
require 'fileutils'
|
|
require 'uri'
|
|
require 'set'
|
|
|
|
require 'action_controller/caching/pages'
|
|
require 'action_controller/caching/actions'
|
|
require 'action_controller/caching/sql_cache'
|
|
require 'action_controller/caching/sweeping'
|
|
require 'action_controller/caching/fragments'
|
|
|
|
|
|
module ActionController #:nodoc:
|
|
# Caching is a cheap way of speeding up slow applications by keeping the result of calculations, renderings, and database calls
|
|
# around for subsequent requests. Action Controller affords you three approaches in varying levels of granularity: Page, Action, Fragment.
|
|
#
|
|
# You can read more about each approach and the sweeping assistance by clicking the modules below.
|
|
#
|
|
# Note: To turn off all caching and sweeping, set Base.perform_caching = false.
|
|
#
|
|
#
|
|
# == Caching stores
|
|
#
|
|
# All the caching stores from ActiveSupport::Cache is available to be used as backends for Action Controller caching. This setting only
|
|
# affects action and fragment caching as page caching is always written to disk.
|
|
#
|
|
# Configuration examples (MemoryStore is the default):
|
|
#
|
|
# ActionController::Base.cache_store = :memory_store
|
|
# ActionController::Base.cache_store = :file_store, "/path/to/cache/directory"
|
|
# ActionController::Base.cache_store = :drb_store, "druby://localhost:9192"
|
|
# ActionController::Base.cache_store = :mem_cache_store, "localhost"
|
|
# ActionController::Base.cache_store = MyOwnStore.new("parameter")
|
|
module Caching
|
|
def self.included(base) #:nodoc:
|
|
base.class_eval do
|
|
@@cache_store = nil
|
|
cattr_reader :cache_store
|
|
|
|
# Defines the storage option for cached fragments
|
|
def self.cache_store=(store_option)
|
|
@@cache_store = ActiveSupport::Cache.lookup_store(store_option)
|
|
end
|
|
|
|
include Pages, Actions, Fragments
|
|
include Sweeping, SqlCache if defined?(ActiveRecord)
|
|
|
|
@@perform_caching = true
|
|
cattr_accessor :perform_caching
|
|
|
|
def self.cache_configured?
|
|
perform_caching && cache_store
|
|
end
|
|
end
|
|
end
|
|
|
|
protected
|
|
# Convenience accessor
|
|
def cache(key, options = {}, &block)
|
|
if cache_configured?
|
|
cache_store.fetch(ActiveSupport::Cache.expand_cache_key(key, :controller), options, &block)
|
|
else
|
|
yield
|
|
end
|
|
end
|
|
|
|
|
|
private
|
|
def cache_configured?
|
|
self.class.cache_configured?
|
|
end
|
|
end
|
|
end |