Class: LocalStorageSerialization

DefaultDB.LocalStorageSerialization()

This class handles the relationship between static storage and files on disk.

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.

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.

This class extends the FilesAndRelays class.

Constructor

new LocalStorageSerialization()

Source:

Methods

(async) _load_object_pmse(pmse) → {object}

Called locally. (would be protected in C++)

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 hooked and unhooked.

Parameters:
Name Type Description
pmse object
Source:
Returns:
  • the object managed by the psme (PageableMemStoreElement)
Type
object

application_clear_large_data(obj) → {object}

This method is used in deleting a record.

Makes use of _ids_to_data_rep 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)

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.

Parameters:
Name Type Description
obj object
Source:
Returns:

obj, which was passed in. But, it may be removed from the map holding PageableMemStoreElement instances

Type
object

application_fix_keys_obj(obj, key, field)

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.

Parameters:
Name Type Description
obj object
key string
field string
Source:

(async) application_large_data_from_stash(obj) → {object}

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.

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.

Parameters:
Name Type Description
obj object
Source:
Returns:
  • the object managed by the psme (PageableMemStoreElement)
Type
object

application_stash_large_data(obj, check_presistence) → {object}

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.

Parameters:
Name Type Description
obj object
check_presistence boolean
Source:
Returns:
  • the object passed or the reference to its storage.
Type
object

initialize(conf)

Parameters:
Name Type Description
conf object
Source:

load_dir(blob_dir)

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.

Calls on application_stash_large_data to get the data's rerefence set up in memory.

Parameters:
Name Type Description
blob_dir string
Source:

load_file(file) → {string|boolean}

Synchronous file reading to a string

Parameters:
Name Type Description
file string
Source:
Returns:
  • returns the contents of the file as a string - false on failure
Type
string | boolean

(async) load_missing_or_update(id, obj, data)

Parameters:
Name Type Description
id string
obj object
data object
Source:

prune_storage_map()

override pruning behavior

Usess max_freeloading_time instead of _age_out_delta (???)

Source:

(async) remove_file(file)

Calls on the frameworks file removale method.

Parameters:
Name Type Description
file string
Source:

schedule(sync_function, static_sync_interval)

It is up to application subsclasses to make sure that the schedule method is called. The interval is set to be static_sync_interval. At the interval, this calls static_backup immediately after calling the callers static_backup.

Parameters:
Name Type Description
sync_function function
static_sync_interval Number
Source:

(async) static_backup()

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)

Source: