1.1.1 • Published 5 years ago
@cityssm/map-expire v1.1.1
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-expireUsage
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
expiryMillisis falsy or not given, the value will never be expired.
get(key)
- Returns
undefinedif not exists or expired.