Skip to content

LupCode/node-lup-expires

Repository files navigation

GitHub package.json version npm bundle size GitHub Workflow Status NPM

lup-expires

Offers different data structures that allow temporary storing of objects. Expire time can be defined for stored entries after which they will get automatically deleted.

JavaScript Example

const { ExpireMap } = require("lup-expires);

const map = new ExpireMap({
    defaultExpire: 1000, // Default expire time in milliseconds.
    extendLifespanOnTouch: false, // If true, the lifespan of the entry will be extended on every access of that element.
});
map.set("key1", "value1"); // Will expire in 1000ms
map.set("key2", "value2", 2000); // Will expire in 2000ms

TypeScript Example

import { ExpireMap } from "lup-expires"

const map = new ExpireMap<string, string>({
    defaultExpire: 1000, // Default expire time in milliseconds.
    extendLifespanOnTouch: false, // If true, the lifespan of the entry will be extended on every access of that element.
});
map.set("key1", "value1"); // Will expire in 1000ms
map.set("key2", "value2", 2000); // Will expire in 2000ms

About

Offers different data structures that allow temporary storing of objects

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published