persistent-memo
Like memoize, but persists on local filesystem (node) or localStorage
(browser).
This module works great with tools that do live-reload (nodemon
, budo
, etc.) - expensive computations and fetches can be cached so live-reload feels instantaneous.
installation
npm install persistent-memo
usage
const fetch = ; const memoAsync memoSync = ; const asyncTest = async { // invalidate cache if needed, usually not required // memoAsync.cache.invalidate(); const fetchRes = await ; // this will be slow console; console; console; // this will be slow console; console; console; // this will be fast - cached! console; console; console;}; const syncTest = { // invalidate cache if needed, usually not required // memoSync.cache.invalidate(); const slowOp = ; // this will be slow console; console; console; // this will be slow console; console; console; // this will be fast console; console; console;}; const test = async { await ; console; ;}; ;