getDiff
Compares the cached sets to the requested set 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( set, availableSets )
This determines the minimal amount of data that must be loaded from the base connection by going through each
cached set (availableSets
) and doing a subset check and a
set difference with the requested set (set
).
If set
is a subset of an availableSet
, {cached: set}
will be returned.
If set
is neither a subset of, nor intersects with any availableSets
, {needed: set}
is returned.
If set
has an intersection with one or more availableSets
, 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 set that is not cached
cached: {start: 0, end: 49}, // the intersection, the set that is cached
count: 49 // the size of the needed set
}
Parameters
- set
{Set}
:The set that is being requested.
- availableSets
{Array<Set>}
:An array of available sets in the cache.
Returns
{Promise<Object>}
:
a difference description object. Described above.