Sha256: 54d68797aaa91778945f7215edcc8a04e8755a9cca534d92649c136f8649b149

Contents?: true

Size: 443 Bytes

Versions: 18

Compression:

Stored size: 443 Bytes

Contents

require 'routemaster/cache'

module Routemaster
  module Middleware
    class ExpireCache
      def initialize(app, cache:nil, **_)
        @app    = app
        @cache  = cache || Routemaster::Cache.new
      end

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

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
routemaster-drain-3.6.2 lib/routemaster/middleware/expire_cache.rb
routemaster-drain-3.6.1 lib/routemaster/middleware/expire_cache.rb
routemaster-drain-3.6.0 lib/routemaster/middleware/expire_cache.rb
routemaster-drain-3.5.1 lib/routemaster/middleware/expire_cache.rb
routemaster-drain-3.5.0 lib/routemaster/middleware/expire_cache.rb
routemaster-drain-3.4.0 lib/routemaster/middleware/expire_cache.rb
routemaster-drain-3.3.0 lib/routemaster/middleware/expire_cache.rb
routemaster-drain-3.2.0 lib/routemaster/middleware/expire_cache.rb
routemaster-drain-3.1.0 lib/routemaster/middleware/expire_cache.rb
routemaster-drain-3.0.3 lib/routemaster/middleware/expire_cache.rb
routemaster-drain-3.0.2 lib/routemaster/middleware/expire_cache.rb
routemaster-drain-3.0.1 lib/routemaster/middleware/expire_cache.rb
routemaster-drain-3.0.0 lib/routemaster/middleware/expire_cache.rb
routemaster-drain-2.5.4 lib/routemaster/middleware/expire_cache.rb
routemaster-drain-2.5.3 lib/routemaster/middleware/expire_cache.rb
routemaster-drain-2.5.2 lib/routemaster/middleware/expire_cache.rb
routemaster-drain-2.5.1 lib/routemaster/middleware/expire_cache.rb
routemaster-drain-2.5.0 lib/routemaster/middleware/expire_cache.rb