123456789_123456789_123456789_123456789_123456789_

Class: ActiveSupport::Cache::Strategy::LocalCache::Middleware

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: activesupport/lib/active_support/cache/strategy/local_cache_middleware.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(name, cache) ⇒ Middleware

[ GitHub ]

  
# File 'activesupport/lib/active_support/cache/strategy/local_cache_middleware.rb', line 17

def initialize(name, cache)
  @name = name
  @cache = cache
  @app = nil
end

Instance Attribute Details

#cache (rw)

[ GitHub ]

  
# File 'activesupport/lib/active_support/cache/strategy/local_cache_middleware.rb', line 15

attr_accessor :cache

#name (readonly)

[ GitHub ]

  
# File 'activesupport/lib/active_support/cache/strategy/local_cache_middleware.rb', line 14

attr_reader :name

Instance Method Details

#call(env)

[ GitHub ]

  
# File 'activesupport/lib/active_support/cache/strategy/local_cache_middleware.rb', line 28

def call(env)
  cache.new_local_cache
  response = @app.call(env)
  response[2] = ::Rack::BodyProxy.new(response[2]) do
    cache.unset_local_cache
  end
  cleanup_on_body_close = true
  response
rescue Rack::Utils::InvalidParameterError
  [400, {}, []]
ensure
  cache.unset_local_cache unless cleanup_on_body_close
end

#new(app)

[ GitHub ]

  
# File 'activesupport/lib/active_support/cache/strategy/local_cache_middleware.rb', line 23

def new(app)
  @app = app
  self
end