static-memory is simple way to cache & retrieve data from RAM
Feature
Simple syntax, easy to implements
Support cache Function, Async/Promise, and Normal Value
How to use
constcache=require('static-memory');cache('test',"hello world");// result : "hello world"console.log(cache('test'))// result : "hello world"// other wayfor(vari=0,i<3;i++){cache(()=>{console.log("init");return"hello world";});}/* result : "init" "hello world" "hello world" "hello world"*/
Docs
function ([name], onBlank)
name ( option ) (string) : name of cache value. If name is null or arguments just have onBlank, it will genarate a hash key by curent function position.
onBlank (function) : initValue, it can be result of function, or as primary type, or promise