Module: Sequel::Postgres::StatementCache::DatabaseMethods

Defined in:
lib/sequel/extensions/pg_statement_cache.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(db) ⇒ Object

Setup the after_connect proc for the connection pool to make sure the connection object is extended with the appropriate module. This disconnects any existing connections to ensure that all connections in the pool have been extended appropriately.



277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# File 'lib/sequel/extensions/pg_statement_cache.rb', line 277

def self.extended(db)
  # Respect existing after_connect proc if one is present
  pr = db.opts[:after_connect]

  # Set the after_connect proc to extend the adapter with
  # the statement cache support.
  db.pool.after_connect = db.opts[:after_connect] = proc do |c|
    pr.call(c) if pr
    c.extend(AdapterMethods)
  end

  # Disconnect to make sure all connections get set up with
  # statement cache.
  db.disconnect
end

Instance Method Details

#alter_tableObject

Clear statement caches for all connections when altering tables.



294
295
296
297
# File 'lib/sequel/extensions/pg_statement_cache.rb', line 294

def alter_table(*)
  clear_statement_caches
  super
end

#drop_tableObject

Clear statement caches for all connections when dropping tables.



300
301
302
303
# File 'lib/sequel/extensions/pg_statement_cache.rb', line 300

def drop_table(*)
  clear_statement_caches
  super
end