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.



241
242
243
244
245
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 241

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

Instance Method Details

#[](key) ⇒ Object



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

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

#[]=(sql, key) ⇒ Object



253
254
255
256
257
258
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 253

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

#clearObject



260
261
262
263
264
265
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 260

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

#delete(key) ⇒ Object



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

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

#each(&block) ⇒ Object



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

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

#key?(key) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#lengthObject



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

def length;       @cache.length; end