Module Sequel::Postgres::StatementCache::AdapterMethods
In: lib/sequel/extensions/pg_statement_cache.rb

Methods

Constants

DML_RE = /\A(WITH|SELECT|INSERT|UPDATE|DELETE) /   A regular expression for the types of queries to cache. Any queries not matching this regular expression are not cached.

Attributes

statement_cache  [R]  The StatementCache instance for this connection. Note that each connection has a separate StatementCache, because prepared statements are connection-specific.

Public Class methods

Set the statement_cache for the connection, using the database‘s :statement_cache_opts option.

[Source]

     # File lib/sequel/extensions/pg_statement_cache.rb, line 230
230:         def self.extended(c)
231:           c.instance_variable_set(:@statement_cache, StatementCache.new(c.sequel_db.opts[:statement_cache_opts] || {}){|name| c.deallocate(name)})
232:         end

Public Instance methods

Deallocate on the server the prepared statement with the given name.

[Source]

     # File lib/sequel/extensions/pg_statement_cache.rb, line 241
241:         def deallocate(name)
242:           begin
243:             execute("DEALLOCATE #{name}")
244:           rescue PGError
245:             # table probably got removed, just ignore it
246:           end
247:         end

pg seems to already use the db method (but not the @db instance variable), so use the sequel_db method to access the related Sequel::Database object.

[Source]

     # File lib/sequel/extensions/pg_statement_cache.rb, line 236
236:         def sequel_db
237:           @db
238:         end

[Validate]