-
Notifications
You must be signed in to change notification settings - Fork 27
About QueryCache
Using the QueryCache drastically reduces the workload for the data store. It records certain SPARQL queries and saves the according results. If the SPARQL queries will executed again, no data store work is necessary, because the results of the cache will be used.
// save reference to the QueryCache
$queryCache = Erfurt_App::getInstance()->getQueryCache();
// first you need a reference to an existing model
$model = new Erfurt_Rdf_Model ("http://foo.bar/");
// [...]
// start transaction
$queryCache->startTransaction($uniqueIdentifier);
$result = $model->sparqlQuery("SELECT ?s ...");
$result2 = $model->sparqlQuery("SELECT ?s ...");
// more SPARQL queries / updates / asks ...
// end transaction
$queryCache->endTransaction($uniqueIdentifier);
First you need an existing model. If you want to record a couple of SPARQL queries for caching their results, just use function startTransaction with an unique identifier. You end a transaction by calling function endTransaction with the same unique identifier.
Between this both function calls, you are free to execute any SPARQL query you want (SELECT, UPDATE, ASK). All queries are depending on each other, which means, if there are changes in the data store which changes the result of one of this queries, the adapted one and each associated query will be invalidated too.