static-memory
v1.0.8
Published
Quick way to cache and retrieve data from cache memory
Readme
Description
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
const cache = require('static-memory');
cache('test', "hello world"); // result : "hello world"
console.log(cache('test')) // result : "hello world"
// other way
for(var i=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
