Class: Routemaster::Jobs::CacheAndSweep

Inherits:
Object
  • Object
show all
Defined in:
lib/routemaster/jobs/cache_and_sweep.rb

Overview

Caches a URL using Cache and sweeps the dirty map if successful. Busts the cache if the resource was deleted.

Instance Method Summary collapse

Instance Method Details

#perform(url) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/routemaster/jobs/cache_and_sweep.rb', line 9

def perform(url)
  Dirty::Map.new.sweep_one(url) do
    begin
      cache.get(url)
    rescue Errors::ResourceNotFound
      cache.bust(url)
      true
    end
  end
end