2.0.1 • Published 3 years ago

lite-cache-js v2.0.1

Weekly downloads
2
License
ISC
Repository
github
Last release
3 years ago

Lite! Only ~55 lines.

Caching module to hold any JS values in RAM for quick access. Objects are removed after expire time every 2 minutes or while calling get()

Install

npm i lite-cache-js --save

USAGE

const cache = require('lite-cache-js');

cache.set({key, value, ttl_ms});
cache.get({key, new_ttl_ms});
cache.remove({key});
cache.clear();

get

will return null or value

new_ttl_ms - If set cache's expire date will be set by this ttl. In milliseconds.

 let value = cache.get({key: 'any valid js object key', new_ttl_ms: 300});

set

will set/update value in cache. ttl_ms - time to live in milliseconds. 1000 = 1 second.

cache.set({
   key: 'any valid js object key',
   value: 'any valid object value',
  ttl_ms: 1000,
  })

remove

will remove single value from cache.

cache.remove({key: 'any valid js object key'})

clear

will remove all values from cache

cache.clear();
2.0.1

3 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.0.3

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago