Sha256: 2a77276a8e6b1140b277358b923492b2f7cd972ca5b8488425c3b9f62e589e1e

Contents?: true

Size: 574 Bytes

Versions: 24

Compression:

Stored size: 574 Bytes

Contents

require 'routemaster/cache'
require 'routemaster/dirty/map'

module Routemaster
  module Jobs
    # Caches a URL using {Cache} and sweeps the dirty map if successful.
    # Busts the cache if the resource was deleted.
    class CacheAndSweep
      def perform(url)
        Dirty::Map.new.sweep_one(url) do
          begin
            cache.get(url)
          rescue Errors::ResourceNotFound
            cache.bust(url)
            true
          end
        end
      end

      private

      def cache
        @cache ||= Routemaster::Cache.new
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
routemaster-drain-3.7.1 lib/routemaster/jobs/cache_and_sweep.rb
routemaster-drain-3.7.0 lib/routemaster/jobs/cache_and_sweep.rb
routemaster-drain-3.6.8 lib/routemaster/jobs/cache_and_sweep.rb
routemaster-drain-3.6.7 lib/routemaster/jobs/cache_and_sweep.rb
routemaster-drain-3.6.6 lib/routemaster/jobs/cache_and_sweep.rb
routemaster-drain-3.6.5 lib/routemaster/jobs/cache_and_sweep.rb
routemaster-drain-3.6.4 lib/routemaster/jobs/cache_and_sweep.rb
routemaster-drain-3.6.3 lib/routemaster/jobs/cache_and_sweep.rb
routemaster-drain-3.6.2 lib/routemaster/jobs/cache_and_sweep.rb
routemaster-drain-3.6.1 lib/routemaster/jobs/cache_and_sweep.rb
routemaster-drain-3.6.0 lib/routemaster/jobs/cache_and_sweep.rb
routemaster-drain-3.5.1 lib/routemaster/jobs/cache_and_sweep.rb
routemaster-drain-3.5.0 lib/routemaster/jobs/cache_and_sweep.rb
routemaster-drain-3.4.0 lib/routemaster/jobs/cache_and_sweep.rb
routemaster-drain-3.3.0 lib/routemaster/jobs/cache_and_sweep.rb
routemaster-drain-3.2.0 lib/routemaster/jobs/cache_and_sweep.rb
routemaster-drain-3.1.0 lib/routemaster/jobs/cache_and_sweep.rb
routemaster-drain-3.0.3 lib/routemaster/jobs/cache_and_sweep.rb
routemaster-drain-3.0.2 lib/routemaster/jobs/cache_and_sweep.rb
routemaster-drain-3.0.1 lib/routemaster/jobs/cache_and_sweep.rb