0.0.7 • Published 8 years ago

stupid-cache v0.0.7

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

stupid-cache

A stupid cache implementation

const cache = require('stupid-cache');

const ttl = 1000 * 60 * 60 * 2; // 2 hours
// set value
cache.set('key1', 'value1', ttl);

// retrieve value
cache.get('key1'); // => 'value1'

setTimeout(() => {
  cache.get('key1'); // => undefined 'ttl expired'
}, ttl + 1000);

// delete value
cache.set('key2', 'value2'); // => default ttl is Infinity
cache.del('key2'); // deletes value
cache.get('key2'); // => undefined

// clear entire cache
cache.set('key3', 'value3');
cache.set('key4', 'value4');

cache.clear(); // deletes all keys

cache.get('key3'); // => undefined
cache.get('key4'); // => undefined
0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago