Class: ActiveRecord::ConnectionAdapters::ConnectionPool::LeaseRegistry::WeakKeyMap
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::ConnectionPool::LeaseRegistry::WeakKeyMap
- Defined in:
- lib/active_record/connection_adapters/abstract/connection_pool.rb
Overview
:nodoc:
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #delete(key) ⇒ Object
-
#initialize ⇒ WeakKeyMap
(also: #clear)
constructor
A new instance of WeakKeyMap.
Constructor Details
#initialize ⇒ WeakKeyMap Also known as: clear
Returns a new instance of WeakKeyMap.
152 153 154 155 156 |
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 152 def initialize @map = ObjectSpace::WeakMap.new @values = nil @size = 0 end |
Instance Method Details
#[](key) ⇒ Object
160 161 162 163 |
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 160 def [](key) prune if @map.size != @size @map[key] end |
#[]=(key, value) ⇒ Object
165 166 167 168 169 |
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 165 def []=(key, value) @map[key] = value prune if @map.size != @size value end |
#delete(key) ⇒ Object
171 172 173 174 175 176 177 |
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 171 def delete(key) if value = self[key] self[key] = nil prune end value end |