Class: Routemaster::Middleware::Cache
- Inherits:
-
Object
- Object
- Routemaster::Middleware::Cache
- Defined in:
- lib/routemaster/middleware/cache.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Cache
constructor
A new instance of Cache.
Constructor Details
#initialize(app, options = {}) ⇒ Cache
Returns a new instance of Cache.
10 11 12 13 14 15 |
# File 'lib/routemaster/middleware/cache.rb', line 10 def initialize(app, = {}) @app = app @cache = .fetch(:cache) { Routemaster::Cache.new } @client = .fetch(:client) { Routemaster::Jobs::Client.new } @queue = .fetch(:queue) { Config.queue_name } end |
Instance Method Details
#call(env) ⇒ Object
17 18 19 20 21 22 |
# 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 |