A simple module to synchronously write files to a directory and read them back. It's purpose is to act as a minimalist filesystem cache. The scope of this is limited to NodeJS (not the browser) and the file system (not runtime memory).
npm install --save micro-cache
Have a directory that you want to read and write to
mkdir cache
Now implement this module in your script. See test/index.js for full implementation. This uses winston for logging, you can run this as LOG_LEVEL=debug node index.js for get full output.
importMicroCachefrom'micro-cache';cache=newMicroCache('./cache');// Write and overwrite existingcache.write('validFileName','Any String Will Do');// Write only if it doesn't existcache.write('anotherFileName','More data here',true);// Read a fileletdata=cache.read('anotherFileName');console.log(data);// Delete a filecache.remove('filename');Pull requests are welcomed, but, if you want to add features simply just use one of the other many existing node modules that do caching.
- Clone the repo
- Make your changes
npm run buildnpm run test