Class: Routemaster::Middleware::ExpireCache
- Inherits:
-
Object
- Object
- Routemaster::Middleware::ExpireCache
- Defined in:
- lib/routemaster/middleware/expire_cache.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ ExpireCache
constructor
A new instance of ExpireCache.
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, = {}) @app = app @cache = .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 |