Class: ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter::StatementPool

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/active_record/connection_adapters/oracle_enhanced_adapter.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection, max = 300) ⇒ StatementPool



365
366
367
368
369
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 365

def initialize(connection, max = 300)
  @connection = connection
  @max        = max
  @cache      = {}
end

Instance Method Details

#[](key) ⇒ Object



373
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 373

def [](key);      @cache[key]; end

#[]=(sql, key) ⇒ Object



377
378
379
380
381
382
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 377

def []=(sql, key)
  while @max <= @cache.size
    @cache.shift.last.close
  end
  @cache[sql] = key
end

#clearObject



384
385
386
387
388
389
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 384

def clear
  @cache.values.each do |cursor|
    cursor.close
  end
  @cache.clear
end

#delete(key) ⇒ Object



375
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 375

def delete(key);  @cache.delete(key); end

#each(&block) ⇒ Object



371
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 371

def each(&block); @cache.each(&block); end

#key?(key) ⇒ Boolean



372
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 372

def key?(key);    @cache.key?(key); end

#lengthObject



374
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 374

def length;       @cache.length; end