Class: Routemaster::Middleware::ExpireCache

Inherits:
Object
  • Object
show all
Defined in:
lib/routemaster/middleware/expire_cache.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ ExpireCache

Returns a new instance of ExpireCache.



6
7
8
9
# File 'lib/routemaster/middleware/expire_cache.rb', line 6

def initialize(app, options = {})
  @app    = app
  @cache  = options.fetch(:cache) { Routemaster::Cache.new }
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/routemaster/middleware/expire_cache.rb', line 11

def call(env)
  env.fetch('routemaster.payload', []).each do |event|
    next if event['type'] == 'noop'
    @cache.invalidate(event['url'])
  end
  @app.call(env)
end