map-expire

1.0.2 • Public • Published

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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    209
    • latest

Version History

Package Sidebar

Install

npm i map-expire

Weekly Downloads

179

Version

1.0.2

License

ISC

Unpacked Size

7.25 kB

Total Files

7

Last publish

Collaborators

  • cavitkeskin