Skip to content

A simple node module that allows reading a local file (configuration file) and updating in-memory store in the case of file change.

License

Notifications You must be signed in to change notification settings

look4regev/file-conf-cache

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

File Conf Cache

A simple node js module that allows treating a local file as a configuration database.

This is done by making sure that every property read will efficiently check if the file is updated, if it is, the repository will be updated.

Usage:

var fileConfCache = require('file-conf-cache');

// Init configuration:
const conf = fileConfCache('configuration.json')
//
Define a reader method:

function readerMethod(_, key){
    return _[key];
}

//read data
conf.getValue(readerMethod, 'somevalue')
Reader method

Reader method is left for the client to implment to allow functionallties such as default value:

function readerMethod (_, key, defaultValue){
  return _[key] || defaultValue;
}

conf.getValue(readerMethod, 'non-existing', 'marak') == 'marak'

Or various other more comple logic

About

A simple node module that allows reading a local file (configuration file) and updating in-memory store in the case of file change.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%