123456789_123456789_123456789_123456789_123456789_

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

Do not use. This class is for internal use only.

Class Method Summary

Instance Method Summary

Constructor Details

.newWeakThreadKeyMap

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

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb', line 123

def initialize
  @map = {}
end

Instance Method Details

#[](key)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb', line 131

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

#[]=(key, value)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb', line 135

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

#clear

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb', line 127

def clear
  @map.clear
end