Class: Sequel::Postgres::StatementCache::Statement
- 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
-
#cache_id ⇒ Object
readonly
The id related to the statement, used as part of the prepared statement name.
-
#last_seen ⇒ Object
The last time this statement was seen by the cache, persumably the last time it was executed.
-
#num_executes ⇒ Object
The total number of executions since the statement entered the cache.
Instance Method Summary collapse
-
#initialize(cache_id) ⇒ Statement
constructor
Used when adding entries to the cache, just sets their id.
-
#name ⇒ Object
The name to use for the server side prepared statement.
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_id ⇒ Object (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_seen ⇒ Object
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_executes ⇒ Object
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
#name ⇒ Object
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 |