Module: ActiveRecord::Bogacs::PoolSupport
- Included in:
- DefaultPool, FalsePool
- Defined in:
- lib/active_record/bogacs/pool_support.rb
Instance Attribute Summary collapse
-
#schema_cache ⇒ Object
Returns the value of attribute schema_cache.
Class Method Summary collapse
Instance Method Summary collapse
- #connection_cache_key(owner_thread = Thread.current) ⇒ Object
- #lock_thread=(lock_thread) ⇒ Object
- #new_connection ⇒ Object
-
#reap ⇒ Object
clear_stale_cached_connections! without the deprecation :.
- #remove(conn) ⇒ Object
Instance Attribute Details
#schema_cache ⇒ Object
Returns the value of attribute schema_cache.
11 12 13 |
# File 'lib/active_record/bogacs/pool_support.rb', line 11 def schema_cache @schema_cache end |
Class Method Details
.included(base) ⇒ Object
7 8 9 |
# File 'lib/active_record/bogacs/pool_support.rb', line 7 def self.included(base) base.send :include, ActiveRecord::ConnectionAdapters::QueryCache::ConnectionPoolConfiguration end |
Instance Method Details
#connection_cache_key(owner_thread = Thread.current) ⇒ Object
29 30 31 |
# File 'lib/active_record/bogacs/pool_support.rb', line 29 def connection_cache_key(owner_thread = Thread.current) owner_thread.object_id end |
#lock_thread=(lock_thread) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/active_record/bogacs/pool_support.rb', line 13 def lock_thread=(lock_thread) if lock_thread @lock_thread = Thread.current else @lock_thread = nil end end |
#new_connection ⇒ Object
21 22 23 24 25 |
# File 'lib/active_record/bogacs/pool_support.rb', line 21 def new_connection conn = Base.send(spec.adapter_method, spec.config) conn.schema_cache = schema_cache.dup if schema_cache && conn.respond_to?(:schema_cache=) conn end |
#reap ⇒ Object
clear_stale_cached_connections! without the deprecation :
42 43 44 45 46 47 48 49 50 |
# File 'lib/active_record/bogacs/pool_support.rb', line 42 def reap keys = @reserved_connections.keys - Thread.list.find_all { |t| t.alive? }.map(&:object_id) keys.each do |key| conn = @reserved_connections[key] checkin conn @reserved_connections.delete(key) end end |
#remove(conn) ⇒ Object
Note:
Method not part of the pre 4.0 API (does no exist).
34 35 36 37 38 39 |
# File 'lib/active_record/bogacs/pool_support.rb', line 34 def remove(conn) synchronize do @connections.delete conn release conn end end |