aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/query_cache.rb
Commit message (Collapse)AuthorAgeFilesLines
* Reduce Array allocationsAkira Matsuda2019-07-311-2/+2
|
* Fix query cache for multiple connectionsEileen Uchitelle2018-11-201-4/+11
| | | | | | | | | | Currently the query cache is only aware of one handler so once we added multiple databases switching on the handler we broke query cache for those reading connections. While #34054 is the proper fix, that fix is not straight forward and I want to make sure that the query cache isn't just broken for all other connections not in the main handler.
* Optimize the code inside AR::QueryCache middlewareBogdan Gusiev2018-04-041-11/+4
|
* Use the query cache when connection is already connectedyuuji.yaginuma2018-02-191-6/+6
| | | | Fixes #32021.
* Merge pull request #28869 from eugeneius/query_cache_all_poolsMatthew Draper2017-11-171-6/+9
|\ | | | | Enable query cache on all connection pools
| * Enable query cache on all connection poolsEugene Kenny2017-04-241-6/+9
| | | | | | | | | | | | Since the query cache no longer eagerly checks out a connection, we can enable it on all connection pools at the start of every request, and it will only take effect for requests that actually use those pools.
* | Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-0/+2
| |
* | Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | | | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* | Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
| |
* | Enable query cache if set a configurationsTsukasa OISHI2017-06-291-6/+6
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | ActiveRecord query cache is available when a connection is connected. Therefore, query cache is unavailable when entering the ActiveRecord::Base.cache block without being connected. ```ruby ActiveRecord::Base.cache do Task.find(1) # access to database. Task.find(1) # access to database. unavailable query cache end ``` If we use query cache with batch script etc, we need to connect before that. ```ruby Task.connection ActiveRecord::Base.cache do Task.find(1) # access to database. Task.find(1) # available query cache end ``` Before version 3.1, query cache had been enabled if a configuration was set up. In order to solve the `DATABASE_URL` issue(#8074), ActiveRecord has checked whether a connection is connected or not. Today, ActiveRecord.configurations respect `DATABASE_URL`. https://github.com/rails/rails/blob/master/activerecord/lib/active_record/core.rb#L46
* Configure query caching (per thread) on the connection poolMatthew Draper2016-11-061-2/+9
|
* Try harder to avoid making a connection while releasing itMatthew Draper2016-11-061-2/+2
| | | | connected? doesn't mean what we need here.
* Clear query cache during checkin, instead of an execution callbackMatthew Draper2016-10-271-9/+2
| | | | | | | It doesn't make sense for the query cache to persist while a connection moves through the pool and is assigned to a new thread. [Samuel Cochran & Matthew Draper]
* Clear the correct query cacheSamuel Cochran2016-10-261-4/+4
| | | | | | | | | | | | | | This executor currently relies on `ActiveRecord::Base.connection` not changing between `prepare` and `complete`. If something else returns the current ActiveRecord connection to the pool early then this `complete` call will fail to clear the correct query cache and restore the original `query_cache_enabled` status. This has for example been happening in Sidekiq: https://github.com/mperham/sidekiq/pull/3166 We can just keep track of the connection as part of the exector state.
* Avoid bumping the class serial when invoking executorMatthew Draper2016-10-031-6/+4
|
* Don't attempt to clear active connections unless we'ere connectedSean Griffin2016-06-291-1/+1
| | | | | | Right now with this middleware we are likely always connected, but I'm hoping to change that soon. This is an easy change to pull out on its own.
* Remove unused `ActiveRecord::Base.connection_id`Sean Griffin2016-06-291-6/+2
| | | | | | | | This method appears to have been partially used in connection pool caching, but it was introduced without much reasoning or any tests. One edge case test was added later on, but it was focused on implementation details. This method is no longer used outside of tests, and as such is removed.
* Respect the current `connected?` method when calling `cache`Arthur Neves2016-06-141-2/+2
| | | | | | Before we enable query caching we check if the connection is connected. Before this fix we were always checking against the main connection, and not the model connection.
* Do not attempt to return connection with open transaction to pool (#24610)Sean Griffin2016-04-221-2/+3
| | | | | | | | | | | | | When the query cache completes, if Active Record is still inside of a transaction, it is because the transaction is meant to be left open above this unit of work (such as transactional fixtures in tests). There were several tests around the behavior of "tests" that were invalid, as tests are not run through the executor. They have been changed to reflect the new behavior, which is closer to what actually occurs in Rails tests. Fixes #23989 Fixes #24491 Close #24500
* Directly support stateful executor hooksMatthew Draper2016-04-051-14/+18
| | | | Also, make sure to call the +complete+ hooks if +run+ fails.
* Publish AS::Executor and AS::Reloader APIsMatthew Draper2016-03-021-25/+17
| | | | | | These should allow external code to run blocks of user code to do "work", at a similar unit size to a web request, without needing to get intimate with ActionDipatch.
* remove blank lines in the start of the ActiveRecord filesPonomarev Nikolay2014-07-291-1/+0
|
* Avoid retrieving connection in ActiveRecord::QueryCache multiple times.Guo Xiang Tan2014-07-071-2/+3
|
* Fix typo.Hendy Tanata2012-12-031-2/+2
|
* Cleans and removes 'Examples' tag [ci skip]Alvaro Pereyra2012-12-011-0/+2
|
* Fix #6951. Use query cache/uncache, when using not only database.yml but ↵kennyj2012-10-311-6/+6
| | | | also DATABASE_URL.
* load active_support/core_ext/object/blank in active_support/railsXavier Noria2012-08-021-1/+0
|
* Restore connection_id on error.kennyj2012-07-231-4/+10
|
* use Rack::BodyProxy in activerecord middlewaresSergey Nartimov2012-01-161-35/+10
|
* use thread locals and an instance variable within QueryCache#BodyProxy to ↵Mark J. Titorenko2011-10-071-2/+4
| | | | maintain appropriate linkage with AR database connection across threads
* clear and disable query cache when an exception is raised from called middlewareAaron Patterson2011-08-281-0/+6
|
* Fix inconsistencies by being polite to the wrapped body. Needed for ↵Steve Hodgkiss2011-06-181-0/+8
| | | | Rack::Sendfile to function properly. See issue #1761.
* ensure query cache is cleared when Rack body is closed, fixes bug reported ↵Aaron Patterson2011-05-041-0/+1
| | | | on 951e18abea9c116fc5d6b330ca1dcd2890abe006
* introduce a body proxy to ensure that query cache is enabled during streamingAaron Patterson2011-05-021-3/+24
|
* Adds basic description and title.Rizwan Reza2010-06-161-0/+1
|
* adds missing requires for Object#blank? and Object#present?Xavier Noria2010-03-281-0/+2
|
* ActiveRecord::QueryCache middlewareJoshua Peek2008-12-221-13/+25
|
* Removed query cache rescue as it could cause code to be run twice (closes ↵David Heinemeier Hansson2007-12-071-2/+0
| | | | | | #10408) [DHH] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8329 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fixed that the Query Cache should just be ignored if the database is ↵David Heinemeier Hansson2007-12-061-0/+2
| | | | | | misconfigured (so that the "About your applications environment" works even before the database has been created) [DHH] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8325 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Speed up and simplify query caching.Jeremy Kemper2007-09-171-113/+15
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7498 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Match Fixnum and Float in particular. Rescue dup error and return result.Jeremy Kemper2007-09-081-4/+5
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7420 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Explicitly require active_record/query_cache before using it.Jeremy Kemper2007-09-081-1/+1
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7419 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Ensure QueryCache doesn't try to dup numeric results (does not affect the ↵Michael Koziarski2007-09-021-5/+6
| | | | | | major OS database). Closes #7661 [tomafro, nzkoz] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7399 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* dont call #collect on a string when returning query cache results. Closes ↵Rick Olson2007-07-251-1/+1
| | | | | | #9099 [norbert] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7239 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Perform a deep #dup on query cache results so that modifying activerecord ↵Rick Olson2007-07-251-2/+8
| | | | | | attributes does not modify the cached attributes. [Rick] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7238 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Use the query cache iff Active Record is configured.Jeremy Kemper2007-02-221-8/+16
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6202 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fixed query cache when multiple database connections were involvedTobias Lütke2007-02-211-2/+2
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6195 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Enable active record cache automatically for all actionsTobias Lütke2007-02-211-4/+16
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6189 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* You can now use cache in instance hierachies. This allows ↵Tobias Lütke2007-02-201-3/+15
| | | | | | ActiveRecord::Base.cache { } usage to cache everything git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6179 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Introducing Model.cache { ... } for the occasional query caching needs. ( ↵Tobias Lütke2007-02-061-18/+33
| | | | | | fantastic to reduce the 200 SELECT * from accounts WHERE id=1 queries in your views ) git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6138 5ecf4fe2-1ee6-0310-87b1-e25e094e27de