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.



239
240
241
242
243
# File 'lib/active_record/connection_adapters/oracle_enhanced_adapter.rb', line 239

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

Instance Method Details

#[](key) ⇒ Object



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

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

#[]=(sql, key) ⇒ Object



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

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

#clearObject



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

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

#delete(key) ⇒ Object



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

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

#each(&block) ⇒ Object



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

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

#key?(key) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#lengthObject



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

def length;       @cache.length; end