class ActiveRecord::ConnectionAdapters::MysqlAdapter::StatementPool
Public Class Methods
new(connection, max = 1000)
click to toggle source
Calls superclass method
ActiveRecord::ConnectionAdapters::StatementPool.new
# File lib/active_record/connection_adapters/mysql_adapter.rb, line 101 def initialize(connection, max = 1000) super @cache = Hash.new { |h,pid| h[pid] = {} } end
Public Instance Methods
[](key)
click to toggle source
# File lib/active_record/connection_adapters/mysql_adapter.rb, line 108 def [](key); cache[key]; end
[]=(sql, key)
click to toggle source
# File lib/active_record/connection_adapters/mysql_adapter.rb, line 112 def []=(sql, key) while @max <= cache.size cache.shift.last[:stmt].close end cache[sql] = key end
clear()
click to toggle source
# File lib/active_record/connection_adapters/mysql_adapter.rb, line 119 def clear cache.values.each do |hash| hash[:stmt].close end cache.clear end
delete(key)
click to toggle source
# File lib/active_record/connection_adapters/mysql_adapter.rb, line 110 def delete(key); cache.delete(key); end
each(&block)
click to toggle source
# File lib/active_record/connection_adapters/mysql_adapter.rb, line 106 def each(&block); cache.each(&block); end
key?(key)
click to toggle source
# File lib/active_record/connection_adapters/mysql_adapter.rb, line 107 def key?(key); cache.key?(key); end
length()
click to toggle source
# File lib/active_record/connection_adapters/mysql_adapter.rb, line 109 def length; cache.length; end
Private Instance Methods
cache()
click to toggle source
# File lib/active_record/connection_adapters/mysql_adapter.rb, line 127 def cache @cache[Process.pid] end