getDiff
Compares the cached queries to the requested query and returns a description of what subset can be loaded from the cache and what subset must be loaded from the base connection.
connection.getDiff( query, availableQueries )
This determines the minimal amount of data that must be loaded from the base connection by going through each
cached query (availableQueries) and doing a isSubset check and a
query difference with the requested query (query).
If query is a subset of an availableSet, {cached: query} will be returned.
If query is neither a subset of, nor intersects with any availableQueries, {needed: query} is returned.
If query has an intersection with one or more availableQueries, a description of the difference that has the fewest
missing elements will be returned. An example diff description looks like:
{
needed: {start: 50, end: 99}, // the difference, the query that is not cached
cached: {start: 0, end: 49}, // the intersection, the query that is cached
count: 49 // the size of the needed query
}
Parameters
- query
{Query}:The query that is being requested.
- availableQueries
{Array<Query>}:An array of available queries in the cache.
Returns
{Promise<Object>}:
a difference description object. Described above.