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, local_cache_key) ⇒ Middleware

[ GitHub ]

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

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

Instance Attribute Details

#local_cache_key (readonly)

[ GitHub ]

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

attr_reader :name, :local_cache_key

#name (readonly)

[ GitHub ]

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

attr_reader :name, :local_cache_key

Instance Method Details

#call(env)

[ GitHub ]

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

def call(env)
  LocalCacheRegistry.set_cache_for(local_cache_key, LocalStore.new)
  response = @app.call(env)
  response[2] = ::Rack::BodyProxy.new(response[2]) do
    LocalCacheRegistry.set_cache_for(local_cache_key, nil)
  end
  cleanup_on_body_close = true
  response
rescue Rack::Utils::InvalidParameterError
  [400, {}, []]
ensure
  LocalCacheRegistry.set_cache_for(local_cache_key, nil) unless
    cleanup_on_body_close
end

#new(app)

[ GitHub ]

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

def new(app)
  @app = app
  self
end