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:
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 cause GC crashes: github.com/byroot/rails/pull/3.
Constructor Details
#initialize ⇒ WeakThreadKeyMap
FIXME: On 3.3 we could use ObjectSpace::WeakKeyMap but it currently cause GC crashes: github.com/byroot/rails/pull/3
128 129 130 |
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 128 def initialize @map = {} end |
Instance Method Details
#[](key) ⇒ Object
136 137 138 |
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 136 def [](key) @map[key] end |
#[]=(key, value) ⇒ Object
140 141 142 143 |
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 140 def []=(key, value) @map.select! { |c, _| c&.alive? } @map[key] = value end |
#clear ⇒ Object
132 133 134 |
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 132 def clear @map.clear end |