cache-register
All the good cache-related puns were taken...
Related Projects
Installation
npm install --save cache-register
Usage
Too-Quick Example
async { /* some async operation that takes 5 seconds */} const CacheRegister MemoryStorage } = ; const cachedFunction = ;
Quick Example
//////////////////////////////////////////////////////////////// First, let's assume that we have a slow function, such as:////////////////////////////////////////////////////////////// { return { console; ; };} //////////////////////////////////////////////////////////////// Ugh! So slow! Let's make it faster by caching the results:////////////////////////////////////////////////////////////// const CacheRegister MemoryStorage } = ; // This calls slowAdd and caches the result in a MemoryStoreconst cachedAdd = ; //////////////////////////////////////////////////////////////// That was easy. Now let's try it out!////////////////////////////////////////////////////////////// { console; console; const v1 = await ; console; console; console; const v2 = await ; console; console; console; const v3 = await ; console;} ;