Class: ActiveRecord::ConnectionAdapters::BigqueryAdapter::StatementPool
- Inherits:
-
ConnectionAdapters::StatementPool
- Object
- ConnectionAdapters::StatementPool
- ActiveRecord::ConnectionAdapters::BigqueryAdapter::StatementPool
- Defined in:
- lib/active_record/connection_adapters/bigquery_adapter.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(sql, key) ⇒ Object
- #clear ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(connection, max) ⇒ StatementPool
constructor
A new instance of StatementPool.
- #key?(key) ⇒ Boolean
- #length ⇒ Object
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 |
#clear ⇒ Object
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
425 |
# File 'lib/active_record/connection_adapters/bigquery_adapter.rb', line 425 def key?(key); cache.key?(key); end |
#length ⇒ Object
427 |
# File 'lib/active_record/connection_adapters/bigquery_adapter.rb', line 427 def length; cache.length; end |