simple-cache-object
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Simple cache object

Usage example

const { SimpleCache } = require('simple-cache');

const cache = new SimpleCache({ age: 60 * 1000 }); // 1 minute cache 
cache.set('test1', 123);
cache.set('test2', {
    a: 3,
    b: 4
})
cache.set('test3', 'fdfd');

cache.get('test1'); // 123
cache.get('test2'); // { a: 3, b: 4 }
cahce.get('test3'); // 'fdfd'

// after 80 sec
setTimeout(() => {
    // values expired
    cache.get('test1'); // undefined
    cache.get('test2'); // undefined
    cahce.get('test3'); // undefined
}, 80 * 1000); 

Options

  • age Max age in ms. By default Infinity

Readme

Keywords

Package Sidebar

Install

npm i simple-cache-object

Weekly Downloads

2

Version

1.0.1

License

ISC

Unpacked Size

9.08 kB

Total Files

13

Last publish

Collaborators

  • aanarion