Class: ActiveRecord::ConnectionAdapters::ConnectionPool::WeakThreadKeyMap

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/connection_adapters/abstract/connection_pool.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initializeWeakThreadKeyMap

FIXME: On 3.3 we could use ObjectSpace::WeakKeyMap but it currently cause GC crashes: github.com/byroot/rails/pull/3



124
125
126
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 124

def initialize
  @map = {}
end

Instance Method Details

#[](key) ⇒ Object



132
133
134
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 132

def [](key)
  @map[key]
end

#[]=(key, value) ⇒ Object



136
137
138
139
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 136

def []=(key, value)
  @map.select! { |c, _| c.alive? }
  @map[key] = value
end

#clearObject



128
129
130
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 128

def clear
  @map.clear
end