/usr/lib/ruby/vendor_ruby/active_support/cache/strategy/local_cache_middleware.rb is in ruby-activesupport 2:4.2.10-0ubuntu4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | require 'rack/body_proxy'
require 'rack/utils'
module ActiveSupport
module Cache
module Strategy
module LocalCache
#--
# This class wraps up local storage for middlewares. Only the middleware method should
# construct them.
class Middleware # :nodoc:
attr_reader :name, :local_cache_key
def initialize(name, local_cache_key)
@name = name
@local_cache_key = local_cache_key
@app = nil
end
def new(app)
@app = app
self
end
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
response
rescue Rack::Utils::InvalidParameterError
LocalCacheRegistry.set_cache_for(local_cache_key, nil)
[400, {}, []]
rescue Exception
LocalCacheRegistry.set_cache_for(local_cache_key, nil)
raise
end
end
end
end
end
end
|