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

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

#clearObject



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

Returns:

  • (Boolean)


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

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

#lengthObject



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

def length;       @cache.length; end