A simple O(1) LRU cache for Node.js, version 1.0.0 (stable). Forked from 'lru' to remove the dependency on 'events', providing a minimal, zero-dependency implementation. Supports set, get, peek, remove, and clear operations with configurable max size and optional max age for automatic eviction. Suitable for scenarios requiring a lightweight, fast LRU cache without external dependencies.
npm install nanolruNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates an LRU cache with max size 2, demonstrates set/get, eviction, remove, keys, and clear.
Always pass a number or { max: number, maxAge?: number } to the constructor.Treat 'cache.keys' as read-only. Do not push, splice, or reassign.
Use cache.get(key) to mark as recently used, or cache.peek(key) to check without updating order.
Use const LRU = require('nanolru')Ensure you use new LRU(max) or new LRU({ max: max })No dependency data recorded yet.