Class: Readyset::Query::CachedQuery
- Inherits:
-
Object
- Object
- Readyset::Query::CachedQuery
- Extended by:
- Queryable
- Includes:
- ActiveModel::AttributeMethods
- Defined in:
- lib/readyset/query/cached_query.rb
Overview
Represents a query that is cached by ReadySet.
Instance Attribute Summary collapse
-
#always ⇒ Object
readonly
Returns the value of attribute always.
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Class Method Summary collapse
-
.all ⇒ Array<CachedQuery>
Returns all of the queries currently cached on ReadySet by invoking the ‘SHOW CACHES` SQL extension on ReadySet.
-
.drop_all! ⇒ void
Drops all the caches that exist on ReadySet.
-
.find(id) ⇒ CachedQuery
Returns the cached query with the given query ID by directly querying ReadySet.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Checks two queries for equality by comparing all of their attributes.
-
#always? ⇒ Boolean
Returns false if the cached query supports falling back to the upstream database and true otherwise.
-
#drop! ⇒ void
Drops the cache associated with this query.
-
#initialize(id: nil, text:, name: nil, always: nil, count: nil) ⇒ CachedQuery
constructor
Constructs a new ‘CachedQuery` from the given attributes.
Constructor Details
#initialize(id: nil, text:, name: nil, always: nil, count: nil) ⇒ CachedQuery
Constructs a new ‘CachedQuery` from the given attributes.
constructed
48 49 50 51 52 53 54 |
# File 'lib/readyset/query/cached_query.rb', line 48 def initialize(id: nil, text:, name: nil, always: nil, count: nil) @id = id @text = text @name = name @always = always @count = count end |
Instance Attribute Details
#always ⇒ Object (readonly)
Returns the value of attribute always.
12 13 14 |
# File 'lib/readyset/query/cached_query.rb', line 12 def always @always end |
#count ⇒ Object (readonly)
Returns the value of attribute count.
12 13 14 |
# File 'lib/readyset/query/cached_query.rb', line 12 def count @count end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/readyset/query/cached_query.rb', line 12 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/readyset/query/cached_query.rb', line 12 def name @name end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
12 13 14 |
# File 'lib/readyset/query/cached_query.rb', line 12 def text @text end |
Class Method Details
.all ⇒ Array<CachedQuery>
Returns all of the queries currently cached on ReadySet by invoking the ‘SHOW CACHES` SQL extension on ReadySet.
18 19 20 |
# File 'lib/readyset/query/cached_query.rb', line 18 def self.all super('SHOW CACHES') end |
.drop_all! ⇒ void
This method returns an undefined value.
Drops all the caches that exist on ReadySet.
25 26 27 28 29 |
# File 'lib/readyset/query/cached_query.rb', line 25 def self.drop_all! Readyset.raw_query('DROP ALL CACHES') nil end |
.find(id) ⇒ CachedQuery
Returns the cached query with the given query ID by directly querying ReadySet. If a cached query with the given ID doesn’t exist, this method raises a ‘Readyset::Query::NotFoundError`.
found
39 40 41 |
# File 'lib/readyset/query/cached_query.rb', line 39 def self.find(id) super('SHOW CACHES WHERE query_id = ?', id) end |
Instance Method Details
#==(other) ⇒ Boolean
Checks two queries for equality by comparing all of their attributes.
60 61 62 63 64 65 |
# File 'lib/readyset/query/cached_query.rb', line 60 def ==(other) id == other.id && text == other.text && name == other.name && always == other.always end |
#always? ⇒ Boolean
Returns false if the cached query supports falling back to the upstream database and true otherwise.
71 72 73 |
# File 'lib/readyset/query/cached_query.rb', line 71 def always? always end |
#drop! ⇒ void
This method returns an undefined value.
Drops the cache associated with this query.
78 79 80 81 |
# File 'lib/readyset/query/cached_query.rb', line 78 def drop! Readyset.drop_cache!(name) ProxiedQuery.find(id) end |