Sha256: 4d0787f6a5055cdf12ac4ae51d27eee08bfb9421ad7ee8c4cd42fffcca5151ec
Contents?: true
Size: 1.58 KB
Versions: 3
Compression:
Stored size: 1.58 KB
Contents
require 'cache_advance' require 'cache_advance/active_record_sweeper' require "#{RAILS_ROOT}/config/caches" require 'dispatcher' # Setup the sweeper and cache types as appropriate for Rails. CacheAdvance.cache_set.sweeper_type = CacheAdvance::ActiveRecordSweeper CacheAdvance.caching_enabled = config.action_controller.perform_caching # This is the helper method that can be used in rails views/controllers/helpers. # If caching is disabled, just make it yield the results of the block. if config.action_controller.perform_caching ActionController::Base.helper do def cache_it(cache, options={}, &block) CacheAdvance.cache_set.apply(cache, request, options) do capture(&block) end end end else ActionController::Base.helper do def cache_it(cache, options={}, &block) capture(&block) end end end ActionMailer::Base.helper do def cache_it(cache, options={}, &block) capture(&block) end end # This will get called after the standard rails environment is initialized. config.after_initialize do if config.action_controller.perform_caching # This hooks the sweepers into the observer system and adds it to the list. CacheAdvance.cache_set.create_sweepers ActiveRecord::Base.observers << CacheAdvance::ActiveRecordSweeper # In development mode, the models we observe get reloaded with each request. Using # this hook allows us to reload the observer relationships each time as well. ActionController::Dispatcher.to_prepare(:cache_advance_reload) do CacheAdvance::ActiveRecordSweeper.instance.reload_sweeper end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
aub-cache_advance-1.1.0 | rails/init.rb |
aub-cache_advance-1.1.1 | rails/init.rb |
aub-cache_advance-1.1.2 | rails/init.rb |