Registry / storage / node-cache-engine

node-cache-engine

JSON →
library2.0.3jsnpmunverified

High-performance caching library for Node.js and browser environments supporting LRU and LFU eviction policies with O(1) complexity for all operations. Version 2.0.3 requires Node >=18.18.2. Ships TypeScript definitions. Differentiates from other caches by supporting both LRU and LFU engines, custom hash tables via symbols, and a unified API with clearAll and toArray methods for LRU. Offers configurable maximum size. Actively maintained with regular releases.

storage
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Always use named import. CommonJS require works but default is ESM.

import { createCache } from 'node-cache-engine'

Set engine via option string, not imported class.

const cache = createCache({ engine: 'LRU' })

Engine key is uppercase: 'LRU' or 'LFU'.

const cache = createCache({ engine: 'LFU' })

Shows creating a cache instance, adding, getting, checking, removing, and iterating items.

import { createCache } from 'node-cache-engine'; const cache = createCache({ size: 100, engine: 'LRU' }); cache.add('user:123', { name: 'Alice' }); const user = cache.get('user:123'); if (cache.has('user:123')) { cache.remove('user:123'); } console.log(cache.size()); // 0 cache.add('a', 1); console.log(cache.toArray()); // [['a', 1]]
Debug
Known footguns
breakingNode.js version requirement was raised to >=18.18.2 in v2.0.0.
gotchaThe default maximum size is Number.MAX_SAFE_INTEGER, which may cause memory issues if not limited.
deprecatedCustom hash table must implement symbols from package; internal structure may change in minor versions.
gotchaEngine option is case-sensitive: 'LRU' or 'LFU'. Lowercase will treat as invalid and may default silently.
gotchaclearAll() and toArray() are only available on LRU engine, not LFU.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
14 hits · last 30 days
gptbot
3
amazonbot
3
bingbot
1
ahrefsbot
1
bytedance
1
Resources