Skip to content

cachier-db

CachierDB

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.

Kind: global class

new CachierDB([opts], [readFormatter], [writeFormatter], [log])

Constructor

ParamTypeDescription
[opts]TemplateDBOptsThe TemplateDBOpts
[readFormatter]functionThe function(string, readFormatOptions) that will return a formatted string for reading data using the options.readFormatOptions from TemplateOpts as the formatting options. Typically reads are for HTML minification 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]functionThe function(string, writeFormatOptions) that will return a formatted string for writting data using the options.writeFormatOptions from TemplateOpts as the formatting options. Typically reads are for JS minification 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]ObjectThe log for handling logging output
[log.debug]functionA function that will accept debug level logging messages (i.e. debug('some message to log'))
[log.info]functionA function that will accept info level logging messages (i.e. info('some message to log'))
[log.warn]functionA function that will accept warning level logging messages (i.e. warn('some message to log'))
[log.error]functionA function that will accept error level logging messages (i.e. error('some message to log'))

cachierDB.operations

Kind: instance property of CachierDB

cachierDB.register()

Kind: instance method of CachierDB

cachierDB.compile()

Kind: instance method of CachierDB

cachierDB.read()

Kind: instance method of CachierDB

cachierDB.write()

Kind: instance method of CachierDB

cachierDB.clear([all])

Clears templates that may reside in-memory, optionally clears the IndexedDB keys in the cache store(s) and closes any lingering DB connections.

Kind: instance method of CachierDB

ParamTypeDefaultDescription
[all]BooleantrueWhen true all of the keys in the IndexedDB cache store(s) will be removed

Released under the MIT License.