Module: Varnish
- Defined in:
- lib/varnish.rb
Instance Method Summary collapse
Instance Method Details
#make_cacheable(options = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/varnish.rb', line 3 def make_cacheable( = {}) if should_be_cached?() headers['Cache-Control'] = cache_control_text() end if [:depends_on] && request.headers['X_VARNISH'] remember_url_for_obj(request.url, ) end end |
#sweep_cache_for(obj, options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/varnish.rb', line 13 def sweep_cache_for(obj, = {}) return unless obj # cache_data is a frozen hash if cache_data = Rails.cache.read( varnish_cache_key(obj) ) Rails.cache.delete( varnish_cache_key(obj) ) urls = cache_data[:urls] + [:urls].to_a if [:instant] SweeperJob.perform(urls) else Resque.enqueue(SweeperJob, urls) end end end |