blob: 3a307863119dadb795dfac80be2c2e814d52e205 [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: DataCache</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: DataCache</h1>
<section>
<header>
<h2>
DataCache
</h2>
</header>
<article>
<div class="container-overview">
<dt>
<h4 class="name" id="DataCache"><span class="type-signature"></span>new DataCache<span class="signature">(options)</span><span class="type-signature"> &rarr; {<a href="DataCache.html">DataCache</a>}</span></h4>
</dt>
<dd>
<div class="description">
Creates a data cache for a collection that is efficiently loaded on-demand.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
</td>
<td class="description last">Options for the data cache, including name, source, pageSize,
prefetchSize, cacheSize, storage mechanism, and initial prefetch and local-data handler.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line405">line 405</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
A new data cache instance.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="DataCache.html">DataCache</a></span>
</dd>
</dl>
</dd>
</div>
<h3 class="subsection-title">Methods</h3>
<dl>
<dt>
<h4 class="name" id="cancelCount"><span class="type-signature"></span>cancelCount<span class="signature">()</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Aborts the count operation (used within promise callback)
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line482">line 482</a>
</li></ul></dd>
</dl>
</dd>
<dt>
<h4 class="name" id="cancelFilter"><span class="type-signature"></span>cancelFilter<span class="signature">()</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Aborts the filter operation (used within promise callback)
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line840">line 840</a>
</li></ul></dd>
</dl>
</dd>
<dt>
<h4 class="name" id="cancelReadPage"><span class="type-signature"></span>cancelReadPage<span class="signature">()</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Aborts the readPage operation. (used within promise callback)
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line911">line 911</a>
</li></ul></dd>
</dl>
</dd>
<dt>
<h4 class="name" id="cancelReadPage"><span class="type-signature"></span>cancelReadPage<span class="signature">()</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Aborts the savePage operation. (used within promise callback)
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line952">line 952</a>
</li></ul></dd>
</dl>
</dd>
<dt>
<h4 class="name" id="cancelReadRange"><span class="type-signature"></span>cancelReadRange<span class="signature">()</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Aborts the readRange operation (used within promise callback)
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line567">line 567</a>
</li></ul></dd>
</dl>
</dd>
<dt>
<h4 class="name" id="clear"><span class="type-signature"></span>clear<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4>
</dt>
<dd>
<div class="description">
Cancels all running operations and clears all local data associated with this cache.
New read requests made while a clear operation is in progress will not be canceled.
Instead they will be queued for execution once the operation is completed.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line496">line 496</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
A promise that has no value and can't be canceled.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="count"><span class="type-signature"></span>count<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4>
</dt>
<dd>
<div class="description">
Counts the number of items in the collection.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line449">line 449</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
A promise with the number of items.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="filterBack"><span class="type-signature"></span>filterBack<span class="signature">(index, count, predicate)</span><span class="type-signature"> &rarr; {<a href="DjsDeferred.html">DjsDeferred</a>}</span></h4>
</dt>
<dd>
<div class="description">
Filters the cache data based a predicate.
Specifying a negative count value will yield all the items in the cache that satisfy the predicate.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>index</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">The index of the item to start filtering backward from.</td>
</tr>
<tr>
<td class="name"><code>count</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Maximum number of items to include in the result.</td>
</tr>
<tr>
<td class="name"><code>predicate</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">Callback function returning a boolean that determines whether an item should be included in the result or not.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line529">line 529</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
A promise for an array of results.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="DjsDeferred.html">DjsDeferred</a></span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="filterForward"><span class="type-signature"></span>filterForward<span class="signature">(index, count, predicate)</span><span class="type-signature"> &rarr; {<a href="DjsDeferred.html">DjsDeferred</a>}</span></h4>
</dt>
<dd>
<div class="description">
Filters the cache data based a predicate.
Specifying a negative count value will yield all the items in the cache that satisfy the predicate.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>index</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">The index of the item to start filtering forward from.</td>
</tr>
<tr>
<td class="name"><code>count</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Maximum number of items to include in the result.</td>
</tr>
<tr>
<td class="name"><code>predicate</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">Callback function returning a boolean that determines whether an item should be included in the result or not.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line517">line 517</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
A promise for an array of results.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="DjsDeferred.html">DjsDeferred</a></span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="readRange"><span class="type-signature"></span>readRange<span class="signature">(index, count)</span><span class="type-signature"> &rarr; {<a href="DjsDeferred.html">DjsDeferred</a>}</span></h4>
</dt>
<dd>
<div class="description">
Reads a range of adjacent records.
New read requests made while a clear operation is in progress will not be canceled.
Instead they will be queued for execution once the operation is completed.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>index</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Zero-based index of record range to read.</td>
</tr>
<tr>
<td class="name"><code>count</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Number of records in the range.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line541">line 541</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
A promise for an array of records; less records may be returned if the
end of the collection is found.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="DjsDeferred.html">DjsDeferred</a></span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="toObservable"><span class="type-signature"></span>toObservable<span class="signature">()</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Creates an Observable object that enumerates all the cache contents.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line575">line 575</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
A new Observable object that enumerates all the cache contents.
</div>
</dd>
<dt>
<h4 class="name" id="cacheFailureCallback"><span class="type-signature">&lt;inner> </span>cacheFailureCallback<span class="signature">(message)</span><span class="type-signature"> &rarr; {function}</span></h4>
</dt>
<dd>
<div class="description">
Creates a function that handles a callback by setting the cache into failure mode.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>message</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">Message text.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line632">line 632</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Function to use as error callback.
This function will specifically handle problems with critical store resources
during cache initialization.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">function</span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="cancelStateMachine"><span class="type-signature">&lt;inner> </span>cancelStateMachine<span class="signature">(operation, opTargetState, cacheState, <span class="optional">data</span>)</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
State machine describing the behavior for cancelling a read or prefetch operation.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>operation</code></td>
<td class="type">
<span class="param-type"><a href="DataCacheOperation.html">DataCacheOperation</a></span>
</td>
<td class="attributes">
</td>
<td class="description last">Operation being run.</td>
</tr>
<tr>
<td class="name"><code>opTargetState</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
</td>
<td class="description last">Operation state to transition to.</td>
</tr>
<tr>
<td class="name"><code>cacheState</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
</td>
<td class="description last">Current cache state.</td>
</tr>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">This state machine contains behavior common to read and prefetch operations.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line1059">line 1059</a>
</li></ul></dd>
</dl>
</dd>
<dt>
<h4 class="name" id="changeState"><span class="type-signature">&lt;inner> </span>changeState<span class="signature">(newState)</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Updates the cache's state and signals all pending operations of the change.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>newState</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">New cache state.
This method is a no-op if the cache's current state and the new state are the same.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line663">line 663</a>
</li></ul></dd>
</dl>
</dd>
<dt>
<h4 class="name" id="clearStore"><span class="type-signature">&lt;inner> </span>clearStore<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="DjsDeferred.html">DjsDeferred</a>}</span></h4>
</dt>
<dd>
<div class="description">
Removes all the data stored in the cache.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line680">line 680</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
A promise with no value.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="DjsDeferred.html">DjsDeferred</a></span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="dequeueOperation"><span class="type-signature">&lt;inner> </span>dequeueOperation<span class="signature">(operation)</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Removes an operation from the caches queues and changes the cache state to idle.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>operation</code></td>
<td class="type">
<span class="param-type"><a href="DataCacheOperation.html">DataCacheOperation</a></span>
</td>
<td class="description last">Operation to dequeue.
This method is used as a handler for the operation's oncomplete event.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line712">line 712</a>
</li></ul></dd>
</dl>
</dd>
<dt>
<h4 class="name" id="destroyStateMachine"><span class="type-signature">&lt;inner> </span>destroyStateMachine<span class="signature">(operation, opTargetState, cacheState)</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
State machine describing the behavior of a clear operation.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>operation</code></td>
<td class="type">
<span class="param-type"><a href="DataCacheOperation.html">DataCacheOperation</a></span>
</td>
<td class="description last">Operation being run.</td>
</tr>
<tr>
<td class="name"><code>opTargetState</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Operation state to transition to.</td>
</tr>
<tr>
<td class="name"><code>cacheState</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Current cache state.
Clear operations have the highest priority and can't be interrupted by other operations; however,
they will preempt any other operation currently executing.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line1083">line 1083</a>
</li></ul></dd>
</dl>
</dd>
<dt>
<h4 class="name" id="fetchPage"><span class="type-signature">&lt;inner> </span>fetchPage<span class="signature">(start)</span><span class="type-signature"> &rarr; {<a href="DjsDeferred.html">DjsDeferred</a>}</span></h4>
</dt>
<dd>
<div class="description">
Requests data from the cache source.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>start</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Zero-based index of items to request.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line731">line 731</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
A promise for a page object with (i)ndex, (c)ount, (d)ata.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="DjsDeferred.html">DjsDeferred</a></span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="filter"><span class="type-signature">&lt;inner> </span>filter<span class="signature">(index, count, predicate, backwards)</span><span class="type-signature"> &rarr; {<a href="DjsDeferred.html">DjsDeferred</a>}</span></h4>
</dt>
<dd>
<div class="description">
Filters the cache data based a predicate.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>index</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">The index of the item to start filtering from.</td>
</tr>
<tr>
<td class="name"><code>count</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Maximum number of items to include in the result.</td>
</tr>
<tr>
<td class="name"><code>predicate</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">Callback function returning a boolean that determines whether an item should be included in the result or not.</td>
</tr>
<tr>
<td class="name"><code>backwards</code></td>
<td class="type">
<span class="param-type">Boolean</span>
</td>
<td class="description last">True if the filtering should move backward from the specified index, falsey otherwise.
Specifying a negative count value will yield all the items in the cache that satisfy the predicate.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line763">line 763</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
A promise for an array of results.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="DjsDeferred.html">DjsDeferred</a></span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="fireOnIdle"><span class="type-signature">&lt;inner> </span>fireOnIdle<span class="signature">()</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Fires an onidle event if any functions are assigned.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line853">line 853</a>
</li></ul></dd>
</dl>
</dd>
<dt>
<h4 class="name" id="prefetch"><span class="type-signature">&lt;inner> </span>prefetch<span class="signature">(start)</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Creates and starts a new prefetch operation.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>start</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Zero-based index of the items to prefetch.
This method is a no-op if any of the following conditions is true:
1.- prefetchSize is 0
2.- All data has been read and stored locally in the cache.
3.- There is already an all data prefetch operation queued.
4.- The cache has run out of available space (overflowed).</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line863">line 863</a>
</li></ul></dd>
</dl>
</dd>
<dt>
<h4 class="name" id="prefetchStateMachine"><span class="type-signature">&lt;inner> </span>prefetchStateMachine<span class="signature">(operation, opTargetState, cacheState, <span class="optional">data</span>)</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
State machine describing the behavior of a prefetch operation.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>operation</code></td>
<td class="type">
<span class="param-type"><a href="DataCacheOperation.html">DataCacheOperation</a></span>
</td>
<td class="attributes">
</td>
<td class="description last">Operation being run.</td>
</tr>
<tr>
<td class="name"><code>opTargetState</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
</td>
<td class="description last">Operation state to transition to.</td>
</tr>
<tr>
<td class="name"><code>cacheState</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
</td>
<td class="description last">Current cache state.</td>
</tr>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">Prefetch operations have the lowest priority and will be interrupted by operations of
other kinds. A preempted prefetch operation will resume its execution only when the state
of the cache returns to idle.
If a clear operation starts executing then all the prefetch operations are canceled,
even if they haven't started executing yet.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line1130">line 1130</a>
</li></ul></dd>
</dl>
</dd>
<dt>
<h4 class="name" id="readPage"><span class="type-signature">&lt;inner> </span>readPage<span class="signature">(key)</span><span class="type-signature"> &rarr; {<a href="DjsDeferred.html">DjsDeferred</a>}</span></h4>
</dt>
<dd>
<div class="description">
Requests a page from the cache local store.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>key</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Zero-based index of the reuqested page.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line900">line 900</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
A promise for a found flag and page object with (i)ndex, (c)ount, (d)ata, and (t)icks.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="DjsDeferred.html">DjsDeferred</a></span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="readSaveStateMachine"><span class="type-signature">&lt;inner> </span>readSaveStateMachine<span class="signature">(operation, opTargetState, cacheState, <span class="optional">data</span>, isPrefetch)</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
State machine describing the behavior for reading and saving data into the cache.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>operation</code></td>
<td class="type">
<span class="param-type"><a href="DataCacheOperation.html">DataCacheOperation</a></span>
</td>
<td class="attributes">
</td>
<td class="description last">Operation being run.</td>
</tr>
<tr>
<td class="name"><code>opTargetState</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
</td>
<td class="description last">Operation state to transition to.</td>
</tr>
<tr>
<td class="name"><code>cacheState</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
</td>
<td class="description last">Current cache state.</td>
</tr>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">-</td>
</tr>
<tr>
<td class="name"><code>isPrefetch</code></td>
<td class="type">
<span class="param-type">Boolean</span>
</td>
<td class="attributes">
</td>
<td class="description last">Flag indicating whether a read (false) or prefetch (true) operation is running.
This state machine contains behavior common to read and prefetch operations.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line1282">line 1282</a>
</li></ul></dd>
</dl>
</dd>
<dt>
<h4 class="name" id="readStateMachine"><span class="type-signature">&lt;inner> </span>readStateMachine<span class="signature">(operation, opTargetState, cacheState, <span class="optional">data</span>)</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
State machine describing the behavior of a read operation.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>operation</code></td>
<td class="type">
<span class="param-type"><a href="DataCacheOperation.html">DataCacheOperation</a></span>
</td>
<td class="attributes">
</td>
<td class="description last">Operation being run.</td>
</tr>
<tr>
<td class="name"><code>opTargetState</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
</td>
<td class="description last">Operation state to transition to.</td>
</tr>
<tr>
<td class="name"><code>cacheState</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
</td>
<td class="description last">Current cache state.</td>
</tr>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">Read operations have a higher priority than prefetch operations, but lower than
clear operations. They will preempt any prefetch operation currently running
but will be interrupted by a clear operation.
If a clear operation starts executing then all the currently running
read operations are canceled. Read operations that haven't started yet will
wait in the start state until the destory operation finishes.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line1200">line 1200</a>
</li></ul></dd>
</dl>
</dd>
<dt>
<h4 class="name" id="savePage"><span class="type-signature">&lt;inner> </span>savePage<span class="signature">(key, page)</span><span class="type-signature"> &rarr; {<a href="DjsDeferred.html">DjsDeferred</a>}</span></h4>
</dt>
<dd>
<div class="description">
Saves a page to the cache local store.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>key</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Zero-based index of the requested page.</td>
</tr>
<tr>
<td class="name"><code>page</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Object with (i)ndex, (c)ount, (d)ata, and (t)icks.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line938">line 938</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
A promise with no value.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="DjsDeferred.html">DjsDeferred</a></span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="saveSettings"><span class="type-signature">&lt;inner> </span>saveSettings<span class="signature">(success, error)</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Saves the cache's current settings to the local store.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>success</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">Success callback.</td>
</tr>
<tr>
<td class="name"><code>error</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">Errror callback.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line985">line 985</a>
</li></ul></dd>
</dl>
</dd>
<dt>
<h4 class="name" id="storeFailureCallback"><span class="type-signature">&lt;inner> </span>storeFailureCallback<span class="signature">(deferred)</span><span class="type-signature"> &rarr; {function}</span></h4>
</dt>
<dd>
<div class="description">
Creates a function that handles a store error.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>deferred</code></td>
<td class="type">
<span class="param-type"><a href="DjsDeferred.html">DjsDeferred</a></span>
</td>
<td class="description last">Deferred object to resolve.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line1007">line 1007</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Function to use as error callback.
This function will specifically handle problems when interacting with the store.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">function</span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="updateSettings"><span class="type-signature">&lt;inner> </span>updateSettings<span class="signature">(page, pageBytes)</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Updates the cache's settings based on a page object.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>page</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Object with (i)ndex, (c)ount, (d)ata.</td>
</tr>
<tr>
<td class="name"><code>pageBytes</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Size of the page in bytes.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="cache.js.html">cache.js</a>, <a href="cache.js.html#line1027">line 1027</a>
</li></ul></dd>
</dl>
</dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Index</a></h2><h3>Modules</h3><ul><li><a href="module-cache.html">cache</a></li><li><a href="source.html">cache/source</a></li><li><a href="module-odata.html">odata</a></li><li><a href="batch.html">odata/batch</a></li><li><a href="handler.html">odata/handler</a></li><li><a href="json.html">odata/json</a></li><li><a href="metadata.html">odata/metadata</a></li><li><a href="net.html">odata/net</a></li><li><a href="utils.html">odata/utils</a></li><li><a href="deferred.html">odatajs/deferred</a></li><li><a href="utils_.html">odatajs/utils</a></li><li><a href="xml.html">odatajs/xml</a></li><li><a href="module-store.html">store</a></li><li><a href="dom.html">store/dom</a></li><li><a href="indexeddb.html">store/indexeddb</a></li><li><a href="memory.html">store/memory</a></li></ul><h3>Classes</h3><ul><li><a href="DataCache.html">DataCache</a></li><li><a href="DataCacheOperation.html">DataCacheOperation</a></li><li><a href="DjsDeferred.html">DjsDeferred</a></li><li><a href="dom-DomStore.html">DomStore</a></li><li><a href="indexeddb-IndexedDBStore.html">IndexedDBStore</a></li><li><a href="memory-MemoryStore.html">MemoryStore</a></li><li><a href="ODataCacheSource.html">ODataCacheSource</a></li></ul><h3><a href="global.html">Global</a></h3>
</nav>
<br clear="both">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Thu Apr 09 2015 08:31:26 GMT+0200 (MESZ)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>