Time-aware least recently used (TLRU) cache for Node.js, version 1.1.1. Extends native Map with proactive eviction using a single timer via fun-dispatcher, avoiding linked lists for memory efficiency. Key differentiators: supports per-item TTL, optional LRU mode with maxStoreSize, can revive items on get. Maintained by tinovyatkin. Requires Node >=18, includes TypeScript types.
npm install tlruNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a TLRU cache with max 5 items, each with a default 1 second TTL. Demonstrates set with custom TTL, get, has, and automatic expiration.
Upgrade Node.js to version 18 or later.
Use maxAgeMs instead of maxAge.
Wait for setImmediate or setTimeout(0) before relying on evictions for size or keys.
Use has() to check existence, not truthiness of get() result.
When using defaultLRU: true, you must provide maxStoreSize.
Use import { TLRU } from 'tlru' instead of import TLRU from 'tlru'.Ensure using require('tlru') correctly, or switch to import.Use const lru = new TLRU({...});