class Routemaster::Middleware::Cache

Public Class Methods

new(app, options = {}) click to toggle source
# File lib/routemaster/middleware/cache.rb, line 10
def initialize(app, options = {})
  @app    = app
  @cache  = options.fetch(:cache) { Routemaster::Cache.new }
  @client = options.fetch(:client) { Routemaster::Jobs::Client.new }
  @queue  = options.fetch(:queue) { Config.queue_name }
end

Public Instance Methods

call(env) click to toggle source
# File lib/routemaster/middleware/cache.rb, line 17
def call(env)
  env.fetch('routemaster.dirty', []).each do |url|
    @client.enqueue(@queue, Routemaster::Jobs::CacheAndSweep, url)
  end
  @app.call(env)
end