1.0.2 • Published 3 years ago

map-expire v1.0.2

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

map-expire

Extended Map object with capacity and expire features

install

npm install --save map-expire

usage

const cache = require('map-expire');

cache.set(key, value, duration)

const value = cache.get(key)
cache.delete(key)

or

const MapExpire = require('map-expire/MapExpire');
const options = {
	capacity: 100, 
	duration: 1000 // in millisecond, default expiration time
}
const cache = new MapExpire([], options)

cache.set(key, value, duration)
const value = cache.get(key)
cache.delete(key)

API

  • set(key, value, duration)

    	duration will be set to default value if not given.
  • get(key) returns with undefined if not exists or expired

test

npm test
1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago