Class: ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter::StatementPool
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter::StatementPool
- Includes:
- Enumerable
- Defined in:
- lib/active_record/connection_adapters/oracle_enhanced_adapter.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(sql, key) ⇒ Object
- #clear ⇒ Object
- #delete(key) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(connection, max = 300) ⇒ StatementPool
constructor
A new instance of StatementPool.
- #key?(key) ⇒ Boolean
- #length ⇒ Object
Constructor Details
#initialize(connection, max = 300) ⇒ StatementPool
Returns a new instance of StatementPool.
360 361 362 363 364 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 360 def initialize(connection, max = 300) @connection = connection @max = max @cache = {} end |
Instance Method Details
#[](key) ⇒ Object
368 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 368 def [](key); @cache[key]; end |
#[]=(sql, key) ⇒ Object
372 373 374 375 376 377 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 372 def []=(sql, key) while @max <= @cache.size @cache.shift.last.close end @cache[sql] = key end |
#clear ⇒ Object
379 380 381 382 383 384 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 379 def clear @cache.values.each do |cursor| cursor.close end @cache.clear end |
#delete(key) ⇒ Object
370 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 370 def delete(key); @cache.delete(key); end |
#each(&block) ⇒ Object
366 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 366 def each(&block); @cache.each(&block); end |
#key?(key) ⇒ Boolean
367 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 367 def key?(key); @cache.key?(key); end |
#length ⇒ Object
369 |
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 369 def length; @cache.length; end |