Class: LocalStorageLifeCycle

DefaultDB.LocalStorageLifeCycle()

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.

This class keeps objects in time buckets. If an object is accessed it will be moved to a newer bucket.

Constructor

new LocalStorageLifeCycle()

Source:

Methods

(tstamp, id)

Parameters:
Name Type Description
tstamp Number
id string
Source:

add_t_stamp(tstamp, id)

Parameters:
Name Type Description
tstamp Number

a timestamp

id string
Source:

add_to_storage_map(obj) → {Error|boolean}

Put an object into a timestamp map.

If the object does not have a wide area id, then this method makes one and adds it in the _id field.

Parameters:
Name Type Description
obj object
Source:
Returns:
  • if the object is stored, returns an Error, otherwise false (indicates to bypass error handling)
Type
Error | boolean

chrono_update_all()

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...

Source:

hash_from_key(id) → {string|boolean}

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.

Parameters:
Name Type Description
id string
Source:
Returns:
  • the universal hash of the object or false
Type
string | boolean

id_maker() → {string}

Calls global_appwide_token on behalf of the class.

Subclasses should override if they want to use this class outside the context of a Copious Transitions application.

Source:
Returns:
  • the wide are id for the object
Type
string

(async) initialize(conf)

Look for a special subobject in configurations for this configuration. For example, StaticDB has conf.static_db.

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.

Parameters:
Name Type Description
conf object
Source:

(async) local_db_load_map() → {object}

Reads in the storage map from disk and loads it.

Source:
Returns:

the storage map object that is in the file on disk as an object.

Type
object

(async) local_db_store_map(storage_map)

Stores the _storage_map object in the file db_file.

Parameters:
Name Type Description
storage_map object
Source:

missing(obj) → {boolean}

Returns true if the object is not in the storage map

Parameters:
Name Type Description
obj object
Source:
Returns:
Type
boolean

object_add_t_stamp(obj)

Put the object in a timestamp bucket when it is first placed into storage.

Parameters:
Name Type Description
obj object
Source:

object_update_stamp(obj)

Changes the timestamp of the object calling update_stamp after the object wide area id has been found.

Parameters:
Name Type Description
obj object
Source:

prune_storage_map()

Prune storage based on time stamps and the current processor time.

Source:

remove_from_storage_map(id) → {boolean}

Erases the object form the _storage_map

Parameters:
Name Type Description
id string
Source:
Returns:

true for success - false otherwise

Type
boolean

update_stamp(tstamp, id) → {Number}

when data is touched make it newer

Removes the object from an old bucket and puts it in a new one.

Parameters:
Name Type Description
tstamp Number
id string
Source:
Returns:
  • the new timestamp
Type
Number