npm.io
1.0.1 • Published 5 years ago

s-memory-cache

Licence
ISC
Version
1.0.1
Deps
0
Size
4 kB
Vulns
0
Weekly
0

simple-memory-cache

A simple memory cache for javascript with no dependencies, built with ES6 proxy

How to install

npm i s-memory-cache

How to use

Basic use:

const initCache = require('s-memory-cache');

const cacheObj = initCache({ refreshCache: 15000, refreshCacheElem: 5000 });

cacheObj['cacheKey1'] = 'hello world';
cacheObj['cacheKey2'] = 'こんにちは世界';

Cache anything you want in cacheObj

The initCache function have two optional parameters:

  • refreshCache: When will the whole cache be reset (in ms)
  • refreshCacheElem: When will the created cache element be reset (in ms)

When the cache element is reset it become null