diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-12-04 05:56:49 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-12-04 05:56:49 +0000 |
commit | dc64887f21d319bb3beb9a71dcc487641ebf8c1f (patch) | |
tree | f1cae8b32771df569d249c542f78a06bed1fda49 /activerecord/lib/active_record/connection_adapters | |
parent | 1dfa0bd3728a6c3b8fc037dd6b524044513f5a1d (diff) | |
download | rails-dc64887f21d319bb3beb9a71dcc487641ebf8c1f.tar.gz rails-dc64887f21d319bb3beb9a71dcc487641ebf8c1f.tar.bz2 rails-dc64887f21d319bb3beb9a71dcc487641ebf8c1f.zip |
Connection cache to speed up retrieve_connection and get rid of dirty connection marking. References #428.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3218 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb | 33 | ||||
-rwxr-xr-x | activerecord/lib/active_record/connection_adapters/abstract_adapter.rb | 5 |
2 files changed, 3 insertions, 35 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb index 5ef200fd97..4ef31e8beb 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb @@ -1,28 +1,4 @@ module ActiveRecord - module ConnectionAdapters - module ConnectionManagement - # Check whether the connection should be checked for activity before use. - def needs_verification? - @needs_verification == true - end - - # Flag the connection for an activity check before use. - def needs_verification! - @needs_verification = true - end - - # If the connection is flagged for an activity check, check whether - # it is active and reconnect if not. - def verify! - if needs_verification? - reconnect! unless active? - @needs_verification = false - end - self - end - end - end - # The root class of all active record objects. class Base class ConnectionSpecification #:nodoc: @@ -102,8 +78,8 @@ module ActiveRecord ar_super = ActiveRecord::Base.superclass until klass == ar_super if conn = active_connections[klass.name] - # Validate the active connection before returning it. - conn.verify! + # Reconnect if the connection is inactive. + conn.reconnect! unless conn.active? return conn elsif conn = @@defined_connections[klass.name] # Activate this connection specification. @@ -152,10 +128,5 @@ module ActiveRecord establish_connection spec end end - - # Mark active connections for verification on next retrieve_connection. - def self.mark_active_connections_for_verification! #:nodoc: - active_connections.values.each { |conn| conn.needs_verification! } - end end end diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index bb6202666e..19812dda86 100755 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -19,7 +19,7 @@ module ActiveRecord # SchemaStatements#add_column, SchemaStatements#change_column and # SchemaStatements#remove_column are very useful. class AbstractAdapter - include Quoting, DatabaseStatements, SchemaStatements, ConnectionManagement + include Quoting, DatabaseStatements, SchemaStatements @@row_even = true def initialize(connection, logger = nil) #:nodoc: @@ -69,9 +69,6 @@ module ActiveRecord nil end rescue Exception => e - # Flag connection as possibly dirty; needs verification before use. - self.needs_verification! - # Log message and raise exception. message = "#{e.class.name}: #{e.message}: #{sql}" log_info(message, name, 0) |