Sha256: 07dddb83a9faa53705043a60e04f9e82c5317f218c1a1441c3019f21a075ee8d
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
require 'cache_advance' require 'cache_advance/active_record_sweeper' require 'cache_advance/rails_cache' # Setup the sweeper and cache types as appropriate for Rails. CacheAdvance::Caches.sweeper_type = CacheAdvance::ActiveRecordSweeper CacheAdvance::Caches.cache_type = CacheAdvance::RailsCache require 'config/caches' require 'dispatcher' # This is the helper method that can be used in rails views/controllers/helpers. ActionController::Base.helper do def cache_it(cache, options={}, &block) CacheAdvance::Caches.apply(cache, request, options) do capture(&block) end end end ActionMailer::Base.helper do def cache_it(cache, options={}) yield end end # This will get called after the standard rails environment is initialized. config.after_initialize do # This hooks the sweepers into the observer system and adds it to the list. CacheAdvance::Caches.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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
aub-cache_advance-1.0.5 | rails/init.rb |