CachierDB
new CachierDB([opts], [readFormatter], [writeFormatter], [log])
Persistence cache manager that uses an IndexedDB or LevelDB store for partial content and compilation segments. The type of DB used is first determined by the presence of an indexedDB on the global/window reference that contains either an IDBFactory or other supported IndexedDB-like interface (e.g. LevelUP). When an indexedDB reference is not present, an atempt to load a module using the options.dbTypeName as the module name/path that resolves into a function that takes a location path from options.dbLocName as it's first argument.
Parameters
| Name | Type | Description |
|---|---|---|
| [opts] | TemplateDBOpts | The TemplateDBOpts |
| [readFormatter] | function | The function(string, readFormatOptions) that will return a formatted string for readingdata using the options.readFormatOptions from TemplateOpts as the formatting options. Typically reads are for HTMLminification and/or beautifying. NOTE: Use with caution as syntax errors may result depending on the formatter used and the complexity of the data being formatted! |
| [writeFormatter] | function | The function(string, writeFormatOptions) that will return a formatted string for writtingdata using the options.writeFormatOptions from TemplateOpts as the formatting options. Typically reads are for JSminification and/or beautifying. NOTE: Use with caution as syntax errors may result depending on the formatter used and the complexity of the data being formatted! |
| [log] | Object | The log for handling logging output |
| [log.debug] | function | A function that will accept debug level logging messages (i.e. debug('some message to log')) |
| [log.info] | function | A function that will accept info level logging messages (i.e. info('some message to log')) |
| [log.warn] | function | A function that will accept warning level logging messages (i.e. warn('some message to log')) |
| [log.error] | function | A function that will accept error level logging messages (i.e. error('some message to log')) |
cachierDB.register()
Async: yes
cachierDB.compile()
Async: yes
cachierDB.read()
Async: yes
cachierDB.write()
Async: yes
cachierDB.metadata
cachierDB.stats ⇒ Object
Returns
Object— Combined memory-cache and database-operation statistics.
cachierDB.resetStats() ⇒ Object
Returns
Object— The reset combined statistics.
cachierDB.clearMemory()
Clears in-memory database records and inherited template/render caches without deleting persisted records.
Async: yes
cachierDB.clear([all=true])
Clears templates that may reside in-memory, optionally clears the IndexedDB keys in the cache store(s) and closes any lingering DB connections.
Async: yes
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| [all=true] | Boolean | true | When true all of the keys in the IndexedDB cache store(s) will be removed |
cachierDB.close()
Closes the active database connection and clears in-memory entries without deleting persisted records.
Async: yes