Class: Sequel::Postgres::StatementCache::Statement

Inherits:
Object
  • Object
show all
Defined in:
lib/sequel/extensions/pg_statement_cache.rb

Overview

A simple structure used for the values in the StatementCache’s hash. It does not hold the related SQL, since that is used as the key for the StatementCache’s hash.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cache_id) ⇒ Statement

Used when adding entries to the cache, just sets their id. Uses 0 for num_executes since that is incremented elsewhere. Does not set last_seen since that is set elsewhere to reduce branching.



60
61
62
63
# File 'lib/sequel/extensions/pg_statement_cache.rb', line 60

def initialize(cache_id)
  @num_executes = 0
  @cache_id = cache_id
end

Instance Attribute Details

#cache_idObject (readonly)

The id related to the statement, used as part of the prepared statement name.



55
56
57
# File 'lib/sequel/extensions/pg_statement_cache.rb', line 55

def cache_id
  @cache_id
end

#last_seenObject

The last time this statement was seen by the cache, persumably the last time it was executed.



48
49
50
# File 'lib/sequel/extensions/pg_statement_cache.rb', line 48

def last_seen
  @last_seen
end

#num_executesObject

The total number of executions since the statement entered the cache.



51
52
53
# File 'lib/sequel/extensions/pg_statement_cache.rb', line 51

def num_executes
  @num_executes
end

Instance Method Details

#nameObject

The name to use for the server side prepared statement. Note that this statement might not actually be prepared.



67
68
69
# File 'lib/sequel/extensions/pg_statement_cache.rb', line 67

def name
  "sequel_pgap_#{cache_id}"
end