123456789_123456789_123456789_123456789_123456789_

Class: ActiveRecord::ConnectionAdapters::MysqlAdapter::StatementPool

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: ActiveRecord::ConnectionAdapters::StatementPool
Defined in: activerecord/lib/active_record/connection_adapters/mysql_adapter.rb

Class Method Summary

Instance Attribute Summary

::Enumerable - Included

#many?

Returns true if the enumerable has more than 1 element.

Instance Method Summary

::ActiveRecord::ConnectionAdapters::StatementPool - Inherited

::Enumerable - Included

#exclude?

The negative of the Enumerable#include?.

#index_by

Convert an enumerable to a hash.

#sum

Calculates a sum from the elements.

Constructor Details

.new(connection, max = 1000) ⇒ StatementPool

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/mysql_adapter.rb', line 72

def initialize(connection, max = 1000)
  super
  @cache = Hash.new { |h,pid| h[pid] = {} }
end

Instance Method Details

#[](key)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/mysql_adapter.rb', line 79

def [](key);      cache[key]; end

#[]=(sql, key)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/mysql_adapter.rb', line 83

def []=(sql, key)
  while @max <= cache.size
    cache.shift.last[:stmt].close
  end
  cache[sql] = key
end

#clear

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/mysql_adapter.rb', line 90

def clear
  cache.each_value do |hash|
    hash[:stmt].close
  end
  cache.clear
end

#delete(key)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/mysql_adapter.rb', line 81

def delete(key);  cache.delete(key); end

#each(&block)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/mysql_adapter.rb', line 77

def each(&block); cache.each(&block); end

#key?(key) ⇒ Boolean

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/mysql_adapter.rb', line 78

def key?(key);    cache.key?(key); end

#length

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/mysql_adapter.rb', line 80

def length;       cache.length; end