mindmeld.query_cache module¶
This module contains the query cache implementation.
-
class
mindmeld.query_cache.
QueryCache
(app_path, schema_version_hash)[source]¶ Bases:
object
QueryCache stores ProcessedQuerys and associated metadata in a sqlite3 backed cache to save processing time on reloading the examples later.
-
compatible_version
()[source]¶ Checks to see if the cache db file exists and that the data version matches the current data version.
-
static
get_key
(domain, intent, query_text)[source]¶ Calculates a hash key for the domain, intent and text of an example. This key is required for further interactions with the query cache.
Parameters: Returns: Hash id representing this query
Return type:
-
key_to_row_id
(key)[source]¶ Parameters: key (str) -- A key generated by the QueryCache.get_key() function Returns: Unique id of the query in the cache if it exists Return type: Optional(Integer)
-
put
(key, processed_query)[source]¶ Adds a ProcessedQuery to the cache
Parameters: - key (str) -- A key generated by QueryCache.get_key() for this example
- processed_query (ProcessedQuery) -- The ProcessedQuery generated for this example
Returns: The unique id of the query in the cache.
Return type: integer
-
connection
¶
-
get
[source]¶ Get a cached ProcessedQuery by id. Note -- this call should never fail as it is required that the row_id exist in the database before this method is called. Exceptions may be thrown in the case of database corruption.
The method caches the previously retrieved element because it is common for a set of iterators (examples and labels) to retrieve the same row_id in sequence. The cache prevents extra db lookups in this case.
Parameters: row_id (integer) -- The unique id returned by QueryCache.key_to_row_id() or QueryCache.put(). Returns: The ProcessedQuery associated with the identifier. Return type: ProcessedQuery
-