Class: ActiveRecord::ConnectionAdapters::IngresAdapter::StatementPool
- Inherits:
-
ConnectionAdapters::StatementPool
- Object
- ConnectionAdapters::StatementPool
- ActiveRecord::ConnectionAdapters::IngresAdapter::StatementPool
- Defined in:
- lib/active_record/connection_adapters/ingres_adapter.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(sql, key) ⇒ Object
- #clear ⇒ Object
- #delete(key) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(connection, max = 1000) ⇒ StatementPool
constructor
A new instance of StatementPool.
- #key?(key) ⇒ Boolean
- #length ⇒ Object
Constructor Details
#initialize(connection, max = 1000) ⇒ StatementPool
Returns a new instance of StatementPool.
129 130 131 132 |
# File 'lib/active_record/connection_adapters/ingres_adapter.rb', line 129 def initialize(connection, max = 1000) super @cache = Hash.new { |h,pid| h[pid] = {} } end |
Instance Method Details
#[](key) ⇒ Object
136 |
# File 'lib/active_record/connection_adapters/ingres_adapter.rb', line 136 def [](key); cache[key]; end |
#[]=(sql, key) ⇒ Object
140 141 142 143 144 145 |
# File 'lib/active_record/connection_adapters/ingres_adapter.rb', line 140 def []=(sql, key) while @max < cache.size cache.shift.last[:stmt].close end cache[sql] = key end |
#clear ⇒ Object
147 148 149 150 151 152 |
# File 'lib/active_record/connection_adapters/ingres_adapter.rb', line 147 def clear cache.values.each do |hash| hash[:stmt].close end cache.clear end |
#delete(key) ⇒ Object
138 |
# File 'lib/active_record/connection_adapters/ingres_adapter.rb', line 138 def delete(key); cache.delete(key); end |
#each(&block) ⇒ Object
134 |
# File 'lib/active_record/connection_adapters/ingres_adapter.rb', line 134 def each(&block); cache.each(&block); end |
#key?(key) ⇒ Boolean
135 |
# File 'lib/active_record/connection_adapters/ingres_adapter.rb', line 135 def key?(key); cache.key?(key); end |
#length ⇒ Object
137 |
# File 'lib/active_record/connection_adapters/ingres_adapter.rb', line 137 def length; cache.length; end |