A Simple Json Cache
auto save json data to disk/localStorage when object change. it support nodejs and web.
Build Setup
# install dependenciesnpm install simple-json-cache --save# node testcd node_modules/simple-json-cachenpm run test
API
SimpleJsonCache
- newObject(object,name)
- object.save()
- object.read()
Usage
NodeJS
const SimpleJsonCache = const DiskCache = var sjc = dir: 'cache' debug: true saveDelay: 1000 debug: true //auto load data from cache/data.jsonvar data = sjc datab //auto save data to cache/data.jsondatacc1++ //auto save to data cache/data.json //butdatanewProto='newProto' //this will do nothing when you add a new proto in objectdata //you must invoke save method to save json data
Web(Vue)
const SimpleJsonCache = const StorageCache = Vueprototypesjc = prefix: 'jsc_' debug: true saveDelay: 1000 debug: true //in vue filevar config = thissjc //auto load data from localStorage['jsc_config']configa='sdsasa' //auto save data to localStorage['jsc_config']configb1++ //auto save data to localStorage['jsc_config'] //butconfignewProto='newProto' //this will do nothing when you add a new proto in objectconfig //you must invoke save method to save json data