map-expire
A JavaScript map with entries that expire after a given number of milliseconds.
Based on the work in cavitkeskin/map-expire.
Installation
npm install @cityssm/map-expire
Usage
import { Cache } from "@cityssm/map-expire";
const cache = new Cache();
cache.set(key, value, expiryMillis);
const value = cache.get(key);
Methods
set(key, value, expiryMillis)
- If
expiryMillis
is falsy or not given, the value will never be expired.
get(key)
- Returns
undefined
if not exists or expired.