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
#initialize(connection, max = 1000) ⇒ StatementPool
Returns a new instance of StatementPool.
189
190
191
192
|
# File 'activerecord/lib/active_record/connection_adapters/mysql_adapter.rb', line 189
def initialize(connection, max = 1000)
super
@cache = Hash.new { |h,pid| h[pid] = {} }
end
|
Instance Method Details
196
|
# File 'activerecord/lib/active_record/connection_adapters/mysql_adapter.rb', line 196
def [](key); cache[key]; end
|
#[]=(sql, key) ⇒ Object
200
201
202
203
204
205
|
# File 'activerecord/lib/active_record/connection_adapters/mysql_adapter.rb', line 200
def []=(sql, key)
while @max <= cache.size
cache.shift.last[:stmt].close
end
cache[sql] = key
end
|
207
208
209
210
211
212
|
# File 'activerecord/lib/active_record/connection_adapters/mysql_adapter.rb', line 207
def clear
cache.values.each do |hash|
hash[:stmt].close
end
cache.clear
end
|
#delete(key) ⇒ Object
198
|
# File 'activerecord/lib/active_record/connection_adapters/mysql_adapter.rb', line 198
def delete(key); cache.delete(key); end
|
#each(&block) ⇒ Object
194
|
# File 'activerecord/lib/active_record/connection_adapters/mysql_adapter.rb', line 194
def each(&block); cache.each(&block); end
|
#key?(key) ⇒ Boolean
195
|
# File 'activerecord/lib/active_record/connection_adapters/mysql_adapter.rb', line 195
def key?(key); cache.key?(key); end
|
197
|
# File 'activerecord/lib/active_record/connection_adapters/mysql_adapter.rb', line 197
def length; cache.length; end
|