Callidon / sparql-engine

🚂 A framework for building SPARQL query engines in Javascript/Typescript
https://callidon.github.io/sparql-engine
MIT License
101 stars 14 forks source link

Enable caching of Basic Graph Patterns #40

Closed Callidon closed 4 years ago

Callidon commented 4 years ago

This PR adds support for semantic caching of Basic Graph pattern evaluation.

Basically, the cache will save the results of BGPs already evaluated and, when the engine wants to evaluate a BGP, it will look for the largest subset of the BGP in the cache. If one is available, it will re-use the cached results to speed up query processing.

By default, semantic caching is disabled. You can turn it on/off using the PlanBuilder.useCache and PlanBuilder.disableCache methods, respectively. The useCache method accepts an optional parameter, so you can provide your own implementation of the semantic cache. By defaults, it uses an in-memory LRU cache which stores up to 500MB of items for 20 minutes.

The cache is automatically wired for the evaluation of BGP using Index Joins and Bound Joins algorithms.