Class: ActiveRecord::ConnectionAdapters::BigqueryAdapter::StatementPool

Inherits:
ConnectionAdapters::StatementPool
  • Object
show all
Defined in:
lib/active_record/connection_adapters/bigquery_adapter.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection, max) ⇒ StatementPool

Returns a new instance of StatementPool.



419
420
421
422
# File 'lib/active_record/connection_adapters/bigquery_adapter.rb', line 419

def initialize(connection, max)
  super
  @cache = Hash.new { |h,pid| h[pid] = {} }
end

Instance Method Details

#[](key) ⇒ Object



426
# File 'lib/active_record/connection_adapters/bigquery_adapter.rb', line 426

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

#[]=(sql, key) ⇒ Object



429
430
431
432
433
434
# File 'lib/active_record/connection_adapters/bigquery_adapter.rb', line 429

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

#clearObject



436
437
438
439
440
441
# File 'lib/active_record/connection_adapters/bigquery_adapter.rb', line 436

def clear
  cache.values.each do |hash|
    dealloc hash[:stmt]
  end
  cache.clear
end

#each(&block) ⇒ Object



424
# File 'lib/active_record/connection_adapters/bigquery_adapter.rb', line 424

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

#key?(key) ⇒ Boolean

Returns:

  • (Boolean)


425
# File 'lib/active_record/connection_adapters/bigquery_adapter.rb', line 425

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

#lengthObject



427
# File 'lib/active_record/connection_adapters/bigquery_adapter.rb', line 427

def length; cache.length; end