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

Inherits:
StatementPool show all
Defined in:
activerecord/lib/active_record/connection_adapters/mysql_adapter.rb

Instance Method Summary (collapse)

Methods included from Enumerable

#as_json, #each_with_object, #exclude?, #group_by, #index_by, #many?, #sum

Constructor Details

- (StatementPool) initialize(connection, max = 1000)

A new instance of StatementPool



95
96
97
98
# File 'activerecord/lib/active_record/connection_adapters/mysql_adapter.rb', line 95

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

Instance Method Details

- (Object) [](key)



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

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

- (Object) []=(sql, key)



106
107
108
109
110
111
# File 'activerecord/lib/active_record/connection_adapters/mysql_adapter.rb', line 106

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

- (Object) clear



113
114
115
116
117
118
# File 'activerecord/lib/active_record/connection_adapters/mysql_adapter.rb', line 113

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

- (Object) delete(key)



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

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

- (Object) each(&block)



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

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

- (Boolean) key?(key)

Returns:

  • (Boolean)


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

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

- (Object) length



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

def length;       cache.length; end