Module: ArJdbc::Abstract::StatementCache

Defined Under Namespace

Classes: StatementPool

Instance Method Summary collapse

Instance Method Details

#delete_cached_statement(sql) ⇒ Object



33
34
35
# File 'lib/arjdbc/abstract/statement_cache.rb', line 33

def delete_cached_statement(sql)
  @statements.delete(sql_key(sql))
end

#fetch_cached_statement(sql) ⇒ Object



37
38
39
# File 'lib/arjdbc/abstract/statement_cache.rb', line 37

def fetch_cached_statement(sql)
  @statements[sql_key(sql)] ||= @raw_connection.prepare_statement(sql)
end

#initialize(*args) ⇒ Object

(connection, logger, config)



22
23
24
25
26
27
28
29
30
31
# File 'lib/arjdbc/abstract/statement_cache.rb', line 22

def initialize(*args) # (connection, logger, config)
  super

  # Only say we support the statement cache if we are using prepared statements
  # and have a max number of statements defined
  statement_limit = self.class.type_cast_config_to_integer(@config[:statement_limit])
  @jdbc_statement_cache_enabled = prepared_statements && (statement_limit.nil? || statement_limit > 0)

  @statements = StatementPool.new(statement_limit) # AR (5.0) expects this to be stored as @statements
end