static-memory

1.0.8 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i static-memory

Weekly Downloads

10

Version

1.0.8

License

ISC

Unpacked Size

1.8 kB

Total Files

3

Last publish

Collaborators

  • thangphung