Class: ActiveRecord::ConnectionAdapters::SQLiteAdapter::StatementPool
- Inherits:
-
ActiveRecord::ConnectionAdapters::StatementPool
show all
- Defined in:
- activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
Instance Method Summary
(collapse)
#delete
Methods included from Enumerable
#as_json, #each_with_object, #exclude?, #group_by, #index_by, #many?, #sum
Constructor Details
- (StatementPool) initialize(connection, max)
A new instance of StatementPool
54
55
56
57
|
# File 'activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb', line 54
def initialize(connection, max)
super
@cache = Hash.new { |h,pid| h[pid] = {} }
end
|
Instance Method Details
61
|
# File 'activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb', line 61
def [](key); cache[key]; end
|
- (Object) []=(sql, key)
64
65
66
67
68
69
|
# File 'activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb', line 64
def []=(sql, key)
while @max <= cache.size
dealloc(cache.shift.last[:stmt])
end
cache[sql] = key
end
|
71
72
73
74
75
76
|
# File 'activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb', line 71
def clear
cache.values.each do |hash|
dealloc hash[:stmt]
end
cache.clear
end
|
- (Object) each(&block)
59
|
# File 'activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb', line 59
def each(&block); cache.each(&block); end
|
- (Boolean) key?(key)
60
|
# File 'activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb', line 60
def key?(key); cache.key?(key); end
|
62
|
# File 'activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb', line 62
def length; cache.length; end
|