Skip to content

Instantly share code, notes, and snippets.

@stve
Created June 29, 2010 16:28
Show Gist options
  • Select an option

  • Save stve/457437 to your computer and use it in GitHub Desktop.

Select an option

Save stve/457437 to your computer and use it in GitHub Desktop.
namespace :cache do
namespace :fragment do
desc 'Manually remove all fragment caches'
task :delete => :environment do
ActionController::Base.cache_store.clear
end
end
end
def initialize_cache
unless defined?(RAILS_CACHE)
silence_warnings { Object.const_set "RAILS_CACHE", ActiveSupport::Cache.lookup_store(configuration.cache_store) }
if RAILS_CACHE.respond_to?(:middleware)
# Insert middleware to setup and teardown local cache for each request
configuration.middleware.insert_after(:"ActionController::Failsafe", RAILS_CACHE.middleware)
end
end
end
def initialize_framework_caches
if configuration.frameworks.include?(:action_controller)
ActionController::Base.cache_store ||= RAILS_CACHE
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment