copious-transitions
Version:
Framework for working with frameworks
2,135 lines (519 loc) • 28.2 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: LocalStorageSerialization</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<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: LocalStorageSerialization</h1>
<section>
<header>
<h2><span class="attribs"><span class="type-signature"></span></span>
<span class="ancestors"><a href="DefaultDB.html">DefaultDB</a>.</span>LocalStorageSerialization<span class="signature">()</span><span class="type-signature"></span></h2>
<div class="class-description"><p>This class handles the relationship between static storage and files on disk.</p>
<p>The object map will be stored at predefined intervals. And, some table entries will refer to larger data components
that are better stored in files on disk.</p>
<p>This is a local storage implementation for those applications that do not supply their own in overriding
the general DB methods given by the class DBClass nor by configuring a replacement for this class.</p>
<p>This class extends the FilesAndRelays class.</p></div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<h4 class="name" id="LocalStorageSerialization"><span class="type-signature"></span>new LocalStorageSerialization<span class="signature">()</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="custom_storage_static_db.js.html">custom_storage/static_db.js</a>, <a href="custom_storage_static_db.js.html#line92">line 92</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="_load_object_pmse"><span class="type-signature">(async) </span>_load_object_pmse<span class="signature">(pmse)</span><span class="type-signature"> → {object}</span></h4>
<div class="description">
<p>Called locally. (would be protected in C++)</p>
<p>This loads data from a file if the pmse indicates that the data is no longer in memory.
The psme.update similar to deserialization method that will the state of the psme to indicate the state as 'datao loaded'
The term here is <code>hooked</code> and <code>unhooked</code>.</p>
</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>pmse</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="custom_storage_static_db.js.html">custom_storage/static_db.js</a>, <a href="custom_storage_static_db.js.html#line314">line 314</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<ul>
<li>the object managed by the psme (PageableMemStoreElement)</li>
</ul>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">object</span>
</dd>
</dl>
<h4 class="name" id="application_clear_large_data"><span class="type-signature"></span>application_clear_large_data<span class="signature">(obj)</span><span class="type-signature"> → {object}</span></h4>
<div class="description">
<p>This method is used in deleting a record.</p>
<p>Makes use of <code>_ids_to_data_rep</code> to fetch the psme (PageableMemStoreElement)
Calls the backup method of the for the psme and then deletes the reference from the table.
(Data may be retrieved from disk)</p>
<p>Called by the ancestor FilesAndRelays. In FilesAndRelays, this method is a nooperation.
It is assumed that the static DB will provide custom storage for certain types of obects.</p>
</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>obj</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="custom_storage_static_db.js.html">custom_storage/static_db.js</a>, <a href="custom_storage_static_db.js.html#line364">line 364</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>obj, which was passed in. But, it may be removed from the map holding PageableMemStoreElement instances</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">object</span>
</dd>
</dl>
<h4 class="name" id="application_fix_keys_obj"><span class="type-signature"></span>application_fix_keys_obj<span class="signature">(obj, key, field)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Called by the ancestor FilesAndRelays. In FilesAndRelays, this method is a nooperation.
It is assumed that the static DB will provide custom storage for certain types of obects.</p>
</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>obj</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>key</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>field</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="custom_storage_static_db.js.html">custom_storage/static_db.js</a>, <a href="custom_storage_static_db.js.html#line409">line 409</a>
</li></ul></dd>
</dl>
<h4 class="name" id="application_large_data_from_stash"><span class="type-signature">(async) </span>application_large_data_from_stash<span class="signature">(obj)</span><span class="type-signature"> → {object}</span></h4>
<div class="description">
<p>Part of getting a piece of data. Given are representation of the data is found, the key for the psme (PageableMemStoreElement)
is used to find information for loading the larger object from a file.</p>
<p>Called by the ancestor FilesAndRelays. In FilesAndRelays, this method is a nooperation.
It is assumed that the static DB will provide custom storage for certain types of obects.</p>
</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>obj</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="custom_storage_static_db.js.html">custom_storage/static_db.js</a>, <a href="custom_storage_static_db.js.html#line339">line 339</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<ul>
<li>the object managed by the psme (PageableMemStoreElement)</li>
</ul>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">object</span>
</dd>
</dl>
<h4 class="name" id="application_stash_large_data"><span class="type-signature"></span>application_stash_large_data<span class="signature">(obj, check_presistence)</span><span class="type-signature"> → {object}</span></h4>
<div class="description">
<p>The main goal of this method is to create an instance of PageableMemStoreElement for the object or to
update it. It is called by the FilesAndRelays class when an object is created or when it is updated.</p>
</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>obj</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>check_presistence</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="custom_storage_static_db.js.html">custom_storage/static_db.js</a>, <a href="custom_storage_static_db.js.html#line269">line 269</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<ul>
<li>the object passed or the reference to its storage.</li>
</ul>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">object</span>
</dd>
</dl>
<h4 class="name" id="initialize"><span class="type-signature"></span>initialize<span class="signature">(conf)</span><span class="type-signature"></span></h4>
<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>conf</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="custom_storage_static_db.js.html">custom_storage/static_db.js</a>, <a href="custom_storage_static_db.js.html#line105">line 105</a>
</li></ul></dd>
</dl>
<h4 class="name" id="load_dir"><span class="type-signature"></span>load_dir<span class="signature">(blob_dir)</span><span class="type-signature"></span></h4>
<div class="description">
<p>This method is called as part of initialization.
Take the name of the directory where the application will store blob data.
Reads each file in the directory.</p>
<p>Calls on <code>application_stash_large_data</code> to get the data's rerefence set up in memory.</p>
</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>blob_dir</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="custom_storage_static_db.js.html">custom_storage/static_db.js</a>, <a href="custom_storage_static_db.js.html#line160">line 160</a>
</li></ul></dd>
</dl>
<h4 class="name" id="load_file"><span class="type-signature"></span>load_file<span class="signature">(file)</span><span class="type-signature"> → {string|boolean}</span></h4>
<div class="description">
<p>Synchronous file reading to a string</p>
</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>file</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="custom_storage_static_db.js.html">custom_storage/static_db.js</a>, <a href="custom_storage_static_db.js.html#line121">line 121</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<ul>
<li>returns the contents of the file as a string - false on failure</li>
</ul>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
|
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id="load_missing_or_update"><span class="type-signature">(async) </span>load_missing_or_update<span class="signature">(id, obj, data)</span><span class="type-signature"></span></h4>
<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>id</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>obj</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="custom_storage_static_db.js.html">custom_storage/static_db.js</a>, <a href="custom_storage_static_db.js.html#line383">line 383</a>
</li></ul></dd>
</dl>
<h4 class="name" id="prune_storage_map"><span class="type-signature"></span>prune_storage_map<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
<p>override pruning behavior</p>
<p>Usess <code>max_freeloading_time</code> instead of <code>_age_out_delta</code> (???)</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="custom_storage_static_db.js.html">custom_storage/static_db.js</a>, <a href="custom_storage_static_db.js.html#line191">line 191</a>
</li></ul></dd>
</dl>
<h4 class="name" id="remove_file"><span class="type-signature">(async) </span>remove_file<span class="signature">(file)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Calls on the frameworks file removale method.</p>
</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>file</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="custom_storage_static_db.js.html">custom_storage/static_db.js</a>, <a href="custom_storage_static_db.js.html#line141">line 141</a>
</li></ul></dd>
</dl>
<h4 class="name" id="schedule"><span class="type-signature"></span>schedule<span class="signature">(sync_function, static_sync_interval)</span><span class="type-signature"></span></h4>
<div class="description">
<p>It is up to application subsclasses to make sure that the schedule method is called.
The interval is set to be <code>static_sync_interval</code>. At the interval, this calls <code>static_backup</code>
immediately after calling the callers <code>static_backup</code>.</p>
</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>sync_function</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>static_sync_interval</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="custom_storage_static_db.js.html">custom_storage/static_db.js</a>, <a href="custom_storage_static_db.js.html#line217">line 217</a>
</li></ul></dd>
</dl>
<h4 class="name" id="static_backup"><span class="type-signature">(async) </span>static_backup<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
<p>Write the current data tables out to files.
If memory is getting tight, then objects that have been staying in memory too long are removed.
(This is a very simple ... clumsy - implementation of an LRU)</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="custom_storage_static_db.js.html">custom_storage/static_db.js</a>, <a href="custom_storage_static_db.js.html#line237">line 237</a>
</li></ul></dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Namespaces</h3><ul><li><a href="Contractual.html">Contractual</a></li><li><a href="CopiousTransitions.html">CopiousTransitions</a></li><li><a href="DefaultDB.html">DefaultDB</a></li><li><a href="base.html">base</a></li><li><a href="field_validators.html">field_validators</a></li></ul><h3>Classes</h3><ul><li><a href="Contractual.LocalTObjectCache.html">LocalTObjectCache</a></li><li><a href="Contractual.MimeHandling.html">MimeHandling</a></li><li><a href="Contractual.TransitionHandling.html">TransitionHandling</a></li><li><a href="Contractual.UserHandling.html">UserHandling</a></li><li><a href="CopiousTransitions.CopiousTransitions.html">CopiousTransitions</a></li><li><a href="DefaultDB.CustomizationMethodsByApplication.html">CustomizationMethodsByApplication</a></li><li><a href="DefaultDB.FauxInMemStore.html">FauxInMemStore</a></li><li><a href="DefaultDB.FileMapper.html">FileMapper</a></li><li><a href="DefaultDB.FilesAndRelays.html">FilesAndRelays</a></li><li><a href="DefaultDB.FilesAndRelays_base.html">FilesAndRelays_base</a></li><li><a href="DefaultDB.LocalStaticDB.html">LocalStaticDB</a></li><li><a href="DefaultDB.LocalStorageLifeCycle.html">LocalStorageLifeCycle</a></li><li><a href="DefaultDB.LocalStorageSerialization.html">LocalStorageSerialization</a></li><li><a href="DefaultDB.PageableMemStoreElement.html">PageableMemStoreElement</a></li><li><a href="DefaultDB.PersistenceContracts.html">PersistenceContracts</a></li><li><a href="DefaultDB.RemoteMessaging.html">RemoteMessaging</a></li><li><a href="DefaultDB.StaticDBDefault.html">StaticDBDefault</a></li><li><a href="GeneralUserDBWrapperImpl.html">GeneralUserDBWrapperImpl</a></li><li><a href="SessionTokenManager.html">SessionTokenManager</a></li><li><a href="base.DBClass.html">DBClass</a></li><li><a href="base.EndpointManager.html">EndpointManager</a></li><li><a href="base.GeneralAppLifeCycle.html">GeneralAppLifeCycle</a></li><li><a href="base.GeneralAuth.html">GeneralAuth</a></li><li><a href="base.GeneralBusiness.html">GeneralBusiness</a></li><li><a href="base.GeneralDynamic.html">GeneralDynamic</a></li><li><a href="base.GeneralMiddleWare.html">GeneralMiddleWare</a></li><li><a href="base.GeneralStatic.html">GeneralStatic</a></li><li><a href="base.GeneralTransitionEngImpl.html">GeneralTransitionEngImpl</a></li><li><a href="base.SessionManager.html">SessionManager</a></li><li><a href="base.SessionManager_Lite.html">SessionManager_Lite</a></li><li><a href="base.TaggedTransition.html">TaggedTransition</a></li><li><a href="base.TokenTables.html">TokenTables</a></li><li><a href="base.UserMessageEndpoint.html">UserMessageEndpoint</a></li><li><a href="base.WebSocketManager.html">WebSocketManager</a></li><li><a href="field_validators.DataLookupField.html">DataLookupField</a></li><li><a href="field_validators.EmailField.html">EmailField</a></li><li><a href="field_validators.EmailVerifyField.html">EmailVerifyField</a></li><li><a href="field_validators.FieldTest.html">FieldTest</a></li><li><a href="field_validators.FieldValidatorTools.html">FieldValidatorTools</a></li><li><a href="field_validators.ForeignAuth.html">ForeignAuth</a></li><li><a href="field_validators.GeneralValidator.html">GeneralValidator</a></li><li><a href="field_validators.LengthyAlphabetField.html">LengthyAlphabetField</a></li><li><a href="field_validators.LengthyDigitalField.html">LengthyDigitalField</a></li><li><a href="field_validators.LengthyField.html">LengthyField</a></li><li><a href="field_validators.LengthyStringField.html">LengthyStringField</a></li><li><a href="field_validators.PasswordField.html">PasswordField</a></li><li><a href="field_validators.PasswordVerifyField.html">PasswordVerifyField</a></li><li><a href="field_validators.TypeCheckField.html">TypeCheckField</a></li></ul><h3>Global</h3><ul><li><a href="global.html#generate_password_block">generate_password_block</a></li><li><a href="global.html#load_configuration">load_configuration</a></li><li><a href="global.html#load_parameters">load_parameters</a></li><li><a href="global.html#module_top">module_top</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Tue Oct 31 2023 17:32:59 GMT-0700 (Pacific Daylight Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>