Class: ActiveRecord::ConnectionAdapters::ConnectionPool::WeakThreadKeyMap
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::ConnectionPool::WeakThreadKeyMap
- Defined in:
- lib/active_record/connection_adapters/abstract/connection_pool.rb
Overview
:nodoc:
Direct Known Subclasses
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #clear ⇒ Object
-
#initialize ⇒ WeakThreadKeyMap
constructor
FIXME: On 3.3 we could use ObjectSpace::WeakKeyMap but it currently causes GC crashes: github.com/byroot/rails/pull/3.
Constructor Details
#initialize ⇒ WeakThreadKeyMap
FIXME: On 3.3 we could use ObjectSpace::WeakKeyMap but it currently causes GC crashes: github.com/byroot/rails/pull/3
138 139 140 |
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 138 def initialize @map = {} end |
Instance Method Details
#[](key) ⇒ Object
146 147 148 |
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 146 def [](key) @map[key] end |
#[]=(key, value) ⇒ Object
150 151 152 153 |
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 150 def []=(key, value) @map.select! { |c, _| c&.alive? } @map[key] = value end |
#clear ⇒ Object
142 143 144 |
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 142 def clear @map.clear end |