UNPKG

copious-transitions

Version:
2,269 lines (525 loc) 27.9 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Class: LocalStorageLifeCycle</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: LocalStorageLifeCycle</h1> <section> <header> <h2><span class="attribs"><span class="type-signature"></span></span> <span class="ancestors"><a href="DefaultDB.html">DefaultDB</a>.</span>LocalStorageLifeCycle<span class="signature">()</span><span class="type-signature"></span></h2> <div class="class-description"><p>Handles the management of the storage map and the time for objects to stay in memory completely. Some objects can timeout and be removed from the storage map.</p> <p>This class keeps objects in time buckets. If an object is accessed it will be moved to a newer bucket.</p></div> </header> <article> <div class="container-overview"> <h2>Constructor</h2> <h4 class="name" id="LocalStorageLifeCycle"><span class="type-signature"></span>new LocalStorageLifeCycle<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_files_and_relays.js.html">custom_storage/files_and_relays.js</a>, <a href="custom_storage_files_and_relays.js.html#line148">line 148</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Methods</h3> <h4 class="name" id=""><span class="type-signature"></span><span class="signature">(tstamp, id)</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>tstamp</code></td> <td class="type"> <span class="param-type">Number</span> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>id</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_files_and_relays.js.html">custom_storage/files_and_relays.js</a>, <a href="custom_storage_files_and_relays.js.html#line257">line 257</a> </li></ul></dd> </dl> <h4 class="name" id="add_t_stamp"><span class="type-signature"></span>add_t_stamp<span class="signature">(tstamp, id)</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>tstamp</code></td> <td class="type"> <span class="param-type">Number</span> </td> <td class="description last"><p>a timestamp</p></td> </tr> <tr> <td class="name"><code>id</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last"><ul> <li></li> </ul></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_files_and_relays.js.html">custom_storage/files_and_relays.js</a>, <a href="custom_storage_files_and_relays.js.html#line225">line 225</a> </li></ul></dd> </dl> <h4 class="name" id="add_to_storage_map"><span class="type-signature"></span>add_to_storage_map<span class="signature">(obj)</span><span class="type-signature"> &rarr; {Error|boolean}</span></h4> <div class="description"> <p>Put an object into a timestamp map.</p> <p>If the object does not have a wide area id, then this method makes one and adds it in the <code>_id</code> field.</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_files_and_relays.js.html">custom_storage/files_and_relays.js</a>, <a href="custom_storage_files_and_relays.js.html#line340">line 340</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> <ul> <li>if the object is stored, returns an Error, otherwise false (indicates to bypass error handling)</li> </ul> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Error</span> | <span class="param-type">boolean</span> </dd> </dl> <h4 class="name" id="chrono_update_all"><span class="type-signature"></span>chrono_update_all<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> <p>Updates all the timestamps of all the objects in the storage map. Usually called just in intialization ... starts the clock on each piece of data...</p> </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="custom_storage_files_and_relays.js.html">custom_storage/files_and_relays.js</a>, <a href="custom_storage_files_and_relays.js.html#line373">line 373</a> </li></ul></dd> </dl> <h4 class="name" id="hash_from_key"><span class="type-signature"></span>hash_from_key<span class="signature">(id)</span><span class="type-signature"> &rarr; {string|boolean}</span></h4> <div class="description"> <p>If the object is in the storage map and keyed by the wide area id, then make a hash of the object and return it.</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>id</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_files_and_relays.js.html">custom_storage/files_and_relays.js</a>, <a href="custom_storage_files_and_relays.js.html#line323">line 323</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> <ul> <li>the universal hash of the object or false</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="id_maker"><span class="type-signature"></span>id_maker<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4> <div class="description"> <p>Calls <code>global_appwide_token</code> on behalf of the class.</p> <p>Subclasses should override if they want to use this class outside the context of a Copious Transitions application.</p> </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="custom_storage_files_and_relays.js.html">custom_storage/files_and_relays.js</a>, <a href="custom_storage_files_and_relays.js.html#line313">line 313</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> <ul> <li>the wide are id for the object</li> </ul> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">string</span> </dd> </dl> <h4 class="name" id="initialize"><span class="type-signature">(async) </span>initialize<span class="signature">(conf)</span><span class="type-signature"></span></h4> <div class="description"> <p>Look for a special subobject in configurations for this configuration. For example, StaticDB has <code>conf.static_db</code>.</p> <p>This intializer loads the storage map. The storage map either contains complete objects or partial objects and indicators of where complete objects are stored on local disks.</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>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_files_and_relays.js.html">custom_storage/files_and_relays.js</a>, <a href="custom_storage_files_and_relays.js.html#line168">line 168</a> </li></ul></dd> </dl> <h4 class="name" id="local_db_load_map"><span class="type-signature">(async) </span>local_db_load_map<span class="signature">()</span><span class="type-signature"> &rarr; {object}</span></h4> <div class="description"> <p>Reads in the storage map from disk and loads it.</p> </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="custom_storage_files_and_relays.js.html">custom_storage/files_and_relays.js</a>, <a href="custom_storage_files_and_relays.js.html#line210">line 210</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> <p>the storage map object that is in the file on disk as an object.</p> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">object</span> </dd> </dl> <h4 class="name" id="local_db_store_map"><span class="type-signature">(async) </span>local_db_store_map<span class="signature">(storage_map)</span><span class="type-signature"></span></h4> <div class="description"> <p>Stores the <code>_storage_map</code> object in the file <code>db_file</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>storage_map</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_files_and_relays.js.html">custom_storage/files_and_relays.js</a>, <a href="custom_storage_files_and_relays.js.html#line198">line 198</a> </li></ul></dd> </dl> <h4 class="name" id="missing"><span class="type-signature"></span>missing<span class="signature">(obj)</span><span class="type-signature"> &rarr; {boolean}</span></h4> <div class="description"> <p>Returns true if the object is not in the storage map</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_files_and_relays.js.html">custom_storage/files_and_relays.js</a>, <a href="custom_storage_files_and_relays.js.html#line300">line 300</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> <h4 class="name" id="object_add_t_stamp"><span class="type-signature"></span>object_add_t_stamp<span class="signature">(obj)</span><span class="type-signature"></span></h4> <div class="description"> <p>Put the object in a timestamp bucket when it is first placed into storage.</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_files_and_relays.js.html">custom_storage/files_and_relays.js</a>, <a href="custom_storage_files_and_relays.js.html#line238">line 238</a> </li></ul></dd> </dl> <h4 class="name" id="object_update_stamp"><span class="type-signature"></span>object_update_stamp<span class="signature">(obj)</span><span class="type-signature"></span></h4> <div class="description"> <p>Changes the timestamp of the object calling <code>update_stamp</code> after the object wide area id has been found.</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_files_and_relays.js.html">custom_storage/files_and_relays.js</a>, <a href="custom_storage_files_and_relays.js.html#line286">line 286</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>Prune storage based on time stamps and the current processor time.</p> </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="custom_storage_files_and_relays.js.html">custom_storage/files_and_relays.js</a>, <a href="custom_storage_files_and_relays.js.html#line387">line 387</a> </li></ul></dd> </dl> <h4 class="name" id="remove_from_storage_map"><span class="type-signature"></span>remove_from_storage_map<span class="signature">(id)</span><span class="type-signature"> &rarr; {boolean}</span></h4> <div class="description"> <p>Erases the object form the <code>_storage_map</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>id</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_files_and_relays.js.html">custom_storage/files_and_relays.js</a>, <a href="custom_storage_files_and_relays.js.html#line359">line 359</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> <p>true for success - false otherwise</p> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> <h4 class="name" id="update_stamp"><span class="type-signature"></span>update_stamp<span class="signature">(tstamp, id)</span><span class="type-signature"> &rarr; {Number}</span></h4> <div class="description"> <p>when data is touched make it newer</p> <p>Removes the object from an old bucket and puts it in a new one.</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>tstamp</code></td> <td class="type"> <span class="param-type">Number</span> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>id</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_files_and_relays.js.html">custom_storage/files_and_relays.js</a>, <a href="custom_storage_files_and_relays.js.html#line274">line 274</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> <ul> <li>the new timestamp</li> </ul> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Number</span> </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>