diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-02-26 10:14:40 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-02-26 10:14:40 -0800 |
commit | bf3ddfa28da8ca837ddce8c6744a6c1fd9a51243 (patch) | |
tree | c96839ac99bcf2142939a728b56116679bf0f909 /activesupport/lib/active_support/cache/strategy/local_cache.rb | |
parent | e5e440f477a0b5e06b008ee77e3c635049405957 (diff) | |
parent | 3225898513434ded93fe3abe51ba700f5bd9db84 (diff) | |
download | rails-bf3ddfa28da8ca837ddce8c6744a6c1fd9a51243.tar.gz rails-bf3ddfa28da8ca837ddce8c6744a6c1fd9a51243.tar.bz2 rails-bf3ddfa28da8ca837ddce8c6744a6c1fd9a51243.zip |
Merge branch 'master' into adequaterecord
* master: (55 commits)
[ci skip] Move association class method notes
extract common code in `uuid_test.rb`.
move PostgreSQL UUID tests from `datatype_test.rb` to `uuid_test.rb`.
[ci skip] remove guide section on models in migrations
test case for custom PostgreSQL enum type.
Remove inclusion of rubysl gem for rbx on generated Gemfile
let `insert_record` actuall save the object.
[skip ci] Fix test name typo in app generator tests.
travis s/2.1.0/2.1.1
Bump version of bcrypt gem
Skip test_migrate_revert_add_index_with_name if databases do not allow to create duplicate indexes on the same columns
Optimize getting started guide images, and use png instead of jpg
:scissors: [ci skip]
Point master changelogs to 4-1-stable branch
Add missing parantheses in index_exists?
`ActionDispatch::Head` was replaced by `Rack::Head`. Closes #14191.
[skip ci] Standardized punctuation.
[skip ci] Fix typo in link_to :method option description
refactor, with_locale is not needed because I18n is mocked.
Fix ActionView label translation for more than 10 nested elements
...
Diffstat (limited to 'activesupport/lib/active_support/cache/strategy/local_cache.rb')
-rw-r--r-- | activesupport/lib/active_support/cache/strategy/local_cache.rb | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/activesupport/lib/active_support/cache/strategy/local_cache.rb b/activesupport/lib/active_support/cache/strategy/local_cache.rb index 4eaf57f385..6afb07bd72 100644 --- a/activesupport/lib/active_support/cache/strategy/local_cache.rb +++ b/activesupport/lib/active_support/cache/strategy/local_cache.rb @@ -1,6 +1,5 @@ require 'active_support/core_ext/object/duplicable' require 'active_support/core_ext/string/inflections' -require 'rack/body_proxy' module ActiveSupport module Cache @@ -9,6 +8,8 @@ module ActiveSupport # duration of a block. Repeated calls to the cache for the same key will hit the # in-memory cache for faster access. module LocalCache + autoload :Middleware, 'active_support/cache/strategy/local_cache_middleware' + # Class for storing and registering the local caches. class LocalCacheRegistry # :nodoc: extend ActiveSupport::PerThreadRegistry @@ -64,37 +65,6 @@ module ActiveSupport def with_local_cache use_temporary_local_cache(LocalStore.new) { yield } end - - #-- - # 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 Exception - LocalCacheRegistry.set_cache_for(local_cache_key, nil) - raise - end - end - # Middleware class can be inserted as a Rack handler to be local cache for the # duration of request. def middleware |