getDiff
Compares the available set data to the requested data and returns the data that should be loaded from the cache and the data loaded from the base connection.
connection.getDiff( set, availableSets )
This attempts to find the minimal amount of data to load by
going through each availableSet and doing a subset
test and a set difference with
set.
If set is a subset of an availableSet, {cached: set} will be returned.
If there is a difference of set and an availableSet, the difference
will be what's needed. The intersection of set and that
availableSet will be what's cached. A count will be taken of
what's needed resulting in an object like:
{
needed: {start: 50, end: 99},
cached: {start: 0, end: 49},
count: 49
}
Finally, getDiff will pick the diff objet with the lowest count. If there
is no diff object, {needed: set} is returned.
Parameters
- set
{Set}:The set that is being loaded.
- availableSets
{Array<Set>}:An array of available sets in the cacheConnection.
Returns
{Promise<Object>}: